Misc enhancements (#9)
* deploy docs only for main * Revert "deploy docs only for main" This reverts commit 53e37bd8a43e7e20d5a64bed1b3e00ced551dcae. * init czi specific view * fix build
This commit is contained in:
committed by
Maximilian Kueffner
parent
22fd65773d
commit
e60203b57d
@@ -29,4 +29,4 @@ target_link_libraries(${IMAGELIBLIBNAME}
|
||||
|
||||
target_include_directories(${IMAGELIBLIBNAME}
|
||||
PUBLIC ${OpenCV_INCLUDE_DIRS}
|
||||
PRIVATE ${LIBCZI_INCLUDE_DIR})
|
||||
PUBLIC ${LIBCZI_INCLUDE_DIR})
|
||||
|
||||
@@ -5,6 +5,22 @@
|
||||
|
||||
#include "libCZI.h"
|
||||
|
||||
pixelarium::imaging::PixelariumCzi::PixelariumCzi(const std::string& uri)
|
||||
{
|
||||
if (!std::filesystem::exists(uri))
|
||||
{
|
||||
throw std::runtime_error("Render file not found.");
|
||||
}
|
||||
|
||||
this->is_empty_ = false;
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
|
||||
auto stream = libCZI::CreateStreamFromFile(this->uri_.wstring().c_str());
|
||||
this->czi_reader_ = libCZI::CreateCZIReader();
|
||||
this->czi_reader_->Open(stream);
|
||||
this->image_statistics_ = this->czi_reader_->GetStatistics();
|
||||
}
|
||||
|
||||
std::unique_ptr<cv::Mat> CZISubBlockToCvMat(std::shared_ptr<libCZI::IBitmapData> bitmap, libCZI::PixelType pixeltype)
|
||||
{
|
||||
size_t pixel_size{0};
|
||||
@@ -81,23 +97,9 @@ std::unique_ptr<cv::Mat> CZISubBlockToCvMat(std::shared_ptr<libCZI::IBitmapData>
|
||||
return fill_mat;
|
||||
}
|
||||
|
||||
pixelarium::imaging::PixelariumCzi::PixelariumCzi(const std::string& uri)
|
||||
{
|
||||
if (!std::filesystem::exists(uri))
|
||||
{
|
||||
throw std::runtime_error("Render file not found.");
|
||||
}
|
||||
|
||||
this->is_empty_ = false;
|
||||
this->uri_ = std::filesystem::path(uri);
|
||||
}
|
||||
|
||||
std::unique_ptr<cv::Mat> pixelarium::imaging::PixelariumCzi::TryGetImage()
|
||||
{
|
||||
auto stream = libCZI::CreateStreamFromFile(this->uri_.wstring().c_str());
|
||||
auto cziReader = libCZI::CreateCZIReader();
|
||||
cziReader->Open(stream);
|
||||
auto block = cziReader->ReadSubBlock(0);
|
||||
auto block = this->czi_reader_->ReadSubBlock(0);
|
||||
auto bitmap = block->CreateBitmap();
|
||||
auto res = CZISubBlockToCvMat(bitmap, block->GetSubBlockInfo().pixelType);
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "../IPixelariumImage.hpp"
|
||||
#include "libCZI.h"
|
||||
|
||||
namespace pixelarium::imaging
|
||||
{
|
||||
@@ -15,6 +17,11 @@ class PixelariumCzi : public IPixelariumImage
|
||||
{
|
||||
public:
|
||||
explicit PixelariumCzi(const std::string& uri);
|
||||
~PixelariumCzi()
|
||||
{
|
||||
if (this->czi_reader_)
|
||||
this->czi_reader_->Close();
|
||||
}
|
||||
|
||||
// IPixelariumImage member implementations
|
||||
public:
|
||||
@@ -34,6 +41,8 @@ class PixelariumCzi : public IPixelariumImage
|
||||
|
||||
bool Empty() const noexcept override { return this->is_empty_; }
|
||||
|
||||
const libCZI::SubBlockStatistics& GetStatistics() const { return this->image_statistics_; }
|
||||
|
||||
public:
|
||||
const static ImageFileType type_{ImageFileType::CZI};
|
||||
|
||||
@@ -41,5 +50,9 @@ class PixelariumCzi : public IPixelariumImage
|
||||
// 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_;
|
||||
};
|
||||
} // namespace pixelarium::imaging
|
||||
|
||||
Reference in New Issue
Block a user