build system and module refactoring + simple histogram scratch (#20)
* scratch adding histogram to image views Histograms should come from some sort of histogram service. This is currently just a POC. * custom logger implementation w/o spdlog * missing cmake file * fix tests * use operator<< over direct stream exposure * rm print header * add threading test + refactor towards interface libraries omits the need for =target_include_directories= calls /everywhere/ * rm print header * rm constexpr * templated thread_pool * fix doxyfile * default enable doc building * czi reader refactor * rm erroneous include expression * clang-format * single lib include with PUBLIC visibility * compile imgui stdlib * clang format * documentation update centralize `LogLevelToString` to `ILog.hpp` update docs and examples
This commit is contained in:
committed by
Maximilian Kueffner
parent
b37814204f
commit
c00c2c71ac
@@ -0,0 +1,100 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "ILog.hpp"
|
||||
#include "IPixelariumImage.hpp"
|
||||
#include "libCZI.h"
|
||||
#include "libCZI_Pixels.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct CvPixelTypeAndSize
|
||||
{
|
||||
int size{-1};
|
||||
int type{-1};
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
[[nodiscard]] constexpr auto GetCVPixelTypeAndSize(P p) noexcept -> CvPixelTypeAndSize
|
||||
{
|
||||
switch (p)
|
||||
{
|
||||
case libCZI::PixelType::Gray8:
|
||||
return {1, CV_8U};
|
||||
case libCZI::PixelType::Gray16:
|
||||
return {2, CV_16U};
|
||||
case libCZI::PixelType::Bgr24:
|
||||
return {3, CV_8UC3};
|
||||
case libCZI::PixelType::Bgra32:
|
||||
return {4, CV_8UC4};
|
||||
case libCZI::PixelType::Gray32:
|
||||
return {4, CV_32S};
|
||||
case libCZI::PixelType::Gray32Float:
|
||||
return {4, CV_32F};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
/// @brief An implementation of IImageQuery to work on CZI images.
|
||||
/// @note Check the documentation here https://zeiss.github.io/libczi/pages/mainpage.html#czi-in-a-nutshell
|
||||
struct CziParams : public IImageQuery
|
||||
{
|
||||
/// @brief A map providing the start coordinate for each dimension in the CZI
|
||||
std::unordered_map<libCZI::DimensionIndex, int> dimension_map;
|
||||
};
|
||||
|
||||
/// @brief Implements support for .czi-images in the realm of IPixelariumImage
|
||||
class PixelariumCzi : public IPixelariumImageCvMat
|
||||
{
|
||||
using Log = pixelarium::utils::log::ILog;
|
||||
|
||||
public:
|
||||
explicit PixelariumCzi(const std::string& uri, const Log& log);
|
||||
~PixelariumCzi()
|
||||
{
|
||||
if (this->czi_reader_) this->czi_reader_->Close();
|
||||
}
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<cv::Mat> TryGetImage(const IImageQuery&) override;
|
||||
|
||||
std::vector<std::optional<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not implemented.");
|
||||
}
|
||||
|
||||
public:
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
const libCZI::SubBlockStatistics& GetStatistics() const { return this->image_statistics_; }
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::kCzi};
|
||||
|
||||
private:
|
||||
std::optional<cv::Mat> SubblockToCvMat(int index);
|
||||
|
||||
private:
|
||||
// this should be set by each image getter
|
||||
// after a new cv::Mat could be instantiated
|
||||
bool is_empty_{true};
|
||||
|
||||
libCZI::SubBlockStatistics image_statistics_;
|
||||
|
||||
std::shared_ptr<libCZI::ICZIReader> czi_reader_;
|
||||
|
||||
std::unordered_map<libCZI::DimensionIndex, int> dimension_map_;
|
||||
|
||||
const Log& log_;
|
||||
};
|
||||
} // namespace pixelarium::imaging
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "IPixelariumImage.hpp"
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
/// @brief Implements support for .jpg-images in the realm of IPixelariumImage
|
||||
class PixelariumJpg : public IPixelariumImageCvMat
|
||||
{
|
||||
public:
|
||||
explicit PixelariumJpg(const std::string& url);
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<cv::Mat> TryGetImage(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with jpg.");
|
||||
}
|
||||
|
||||
std::vector<std::optional<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with jpg.");
|
||||
}
|
||||
|
||||
public:
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::kJpg};
|
||||
|
||||
private:
|
||||
// this should be set by each image getter
|
||||
// after a new cv::Mat could be instantiated
|
||||
bool is_empty_{true};
|
||||
};
|
||||
} // namespace pixelarium::imaging
|
||||
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "ILog.hpp"
|
||||
#include "IPixelariumImage.hpp"
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
/// @brief Implements support for in-memory images in the realm of IPixelariumImage
|
||||
class PixelariumMem : public IPixelariumImageCvMat
|
||||
{
|
||||
using Log = pixelarium::utils::log::ILog;
|
||||
|
||||
public:
|
||||
explicit PixelariumMem(const cv::Mat& img, const std::string& name, const Log& log);
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<cv::Mat> TryGetImage(const IImageQuery&) override { throw std::runtime_error("Not implemented."); }
|
||||
|
||||
std::vector<std::optional<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
throw std::runtime_error("Not implemented.");
|
||||
}
|
||||
|
||||
void SetImage(const cv::Mat& img) { this->img_ = img; }
|
||||
|
||||
std::string Name() const noexcept override { return this->name_; }
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::kMemory};
|
||||
|
||||
private:
|
||||
// this should be set by each image getter
|
||||
// after a new cv::Mat could be instantiated
|
||||
bool is_empty_{true};
|
||||
cv::Mat img_;
|
||||
const Log& log_;
|
||||
std::string name_;
|
||||
};
|
||||
} // namespace pixelarium::imaging
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "IPixelariumImage.hpp"
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
/// @brief Implements support for .png-images in the realm of IPixelariumImage
|
||||
class PixelariumPng : public IPixelariumImageCvMat
|
||||
{
|
||||
public:
|
||||
explicit PixelariumPng(const std::string& url);
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<cv::Mat> TryGetImage(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with png.");
|
||||
}
|
||||
|
||||
std::vector<std::optional<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with png.");
|
||||
}
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::kPng};
|
||||
|
||||
private:
|
||||
// this should be set by each image getter
|
||||
// after a new cv::Mat could be instantiated
|
||||
bool is_empty_{true};
|
||||
};
|
||||
} // namespace pixelarium::imaging
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "ILog.hpp"
|
||||
#include "IPixelariumImage.hpp"
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
/// @brief Implements support for .tiff-images in the realm of IPixelariumImage
|
||||
class PixelariumTiff : public IPixelariumImageCvMat
|
||||
{
|
||||
using Log = pixelarium::utils::log::ILog;
|
||||
|
||||
public:
|
||||
explicit PixelariumTiff(const std::string& uri, const Log& log);
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
std::optional<cv::Mat> TryGetImage() override;
|
||||
|
||||
std::optional<cv::Mat> TryGetImage(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with tiff.");
|
||||
}
|
||||
|
||||
std::vector<std::optional<cv::Mat>> TryGetImages(const IImageQuery&) override
|
||||
{
|
||||
// ToDo: proper error
|
||||
throw std::runtime_error("Not possible with tiff.");
|
||||
}
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::kTiff};
|
||||
|
||||
private:
|
||||
// this should be set by each image getter
|
||||
// after a new cv::Mat could be instantiated
|
||||
bool is_empty_{true};
|
||||
const Log& log_;
|
||||
};
|
||||
} // namespace pixelarium::imaging
|
||||
Reference in New Issue
Block a user