From f447f9a97feff2933e8a328bf12d1091d14dc7d0 Mon Sep 17 00:00:00 2001 From: Erik Smistad Date: Thu, 21 Nov 2024 15:39:33 +0100 Subject: [PATCH] Added option to force image pyramid output in PatchStitcher --- .../Algorithms/ImagePatch/PatchStitcher.cpp | 14 ++++++++++++-- .../Algorithms/ImagePatch/PatchStitcher.hpp | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/source/FAST/Algorithms/ImagePatch/PatchStitcher.cpp b/source/FAST/Algorithms/ImagePatch/PatchStitcher.cpp index 2af4ab5d5..0c4466aca 100644 --- a/source/FAST/Algorithms/ImagePatch/PatchStitcher.cpp +++ b/source/FAST/Algorithms/ImagePatch/PatchStitcher.cpp @@ -7,7 +7,7 @@ namespace fast { -PatchStitcher::PatchStitcher(bool patchesAreCropped) { +PatchStitcher::PatchStitcher(bool patchesAreCropped, bool forceImagePyramidOutput) { createInputPort(0); // Can be Image, Batch or Tensor createOutputPort(0); // Can be Image or Tensor @@ -15,6 +15,7 @@ PatchStitcher::PatchStitcher(bool patchesAreCropped) { createOpenCLProgram(Config::getKernelSourcePath() + "/Algorithms/ImagePatch/PatchStitcher3D.cl", "3D"); createBooleanAttribute("patches-are-cropped", "Patches are cropped", "Indicate whether incomming patches are already cropped or not.", false); setPatchesAreCropped(patchesAreCropped); + setForceImagePyramidOutput(forceImagePyramidOutput); } void PatchStitcher::loadAttributes() { @@ -122,7 +123,7 @@ void PatchStitcher::processImage(std::shared_ptr patch) { if(is3D) { m_outputImage = Image::create(fullWidth, fullHeight, fullDepth, patch->getDataType(), patch->getNrOfChannels()); } else { - if(fullWidth < 8192 && fullHeight < 8192) { + if(fullWidth < 8192 && fullHeight < 8192 && !m_forceImagePyramidOutput) { reportInfo() << "Patch stitcher creating image with size " << fullWidth << " " << fullHeight << reportEnd(); m_outputImage = Image::create(fullWidth, fullHeight, patch->getDataType(), patch->getNrOfChannels()); } else { @@ -307,5 +308,14 @@ bool PatchStitcher::getPatchesAreCropped() const { return m_patchesAreCropped; } +void PatchStitcher::setForceImagePyramidOutput(bool force) { + m_forceImagePyramidOutput = force; + setModified(true); +} + +bool PatchStitcher::getForceImagePyramidOutput() const { + return m_forceImagePyramidOutput; +} + } \ No newline at end of file diff --git a/source/FAST/Algorithms/ImagePatch/PatchStitcher.hpp b/source/FAST/Algorithms/ImagePatch/PatchStitcher.hpp index 936f4f766..e63fdbc73 100644 --- a/source/FAST/Algorithms/ImagePatch/PatchStitcher.hpp +++ b/source/FAST/Algorithms/ImagePatch/PatchStitcher.hpp @@ -27,9 +27,12 @@ class FAST_EXPORT PatchStitcher : public ProcessObject { public: /** * @brief Create instance + * @param patchesAreCropped + * @param forceImagePyramidOutput Force output to always be an image pyramid, if source was an image pyramid, + * even if output is small. * @return instance */ - FAST_CONSTRUCTOR(PatchStitcher, bool, patchesAreCropped, = false); + FAST_CONSTRUCTOR(PatchStitcher, bool, patchesAreCropped, = false, bool, forceImagePyramidOutput, = false); void loadAttributes() override; /** * @brief Set whether incoming patches are cropped or not @@ -41,6 +44,17 @@ class FAST_EXPORT PatchStitcher : public ProcessObject { * @param cropped */ bool getPatchesAreCropped() const; + /** + * @brief Force output to always be an image pyramid, if source was an image pyramid, + * even if output is small. + * @param force + */ + void setForceImagePyramidOutput(bool force); + /** + * @brief Get whether output should be forced to be image pyramid + * @return + */ + bool getForceImagePyramidOutput() const; protected: void execute() override; @@ -52,6 +66,7 @@ class FAST_EXPORT PatchStitcher : public ProcessObject { void processImage(std::shared_ptr tensor); private: bool m_patchesAreCropped = false; + bool m_forceImagePyramidOutput = false; };