Skip to content

Commit

Permalink
Added option to force image pyramid output in PatchStitcher
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Nov 21, 2024
1 parent ac554f7 commit f447f9a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
14 changes: 12 additions & 2 deletions source/FAST/Algorithms/ImagePatch/PatchStitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

namespace fast {

PatchStitcher::PatchStitcher(bool patchesAreCropped) {
PatchStitcher::PatchStitcher(bool patchesAreCropped, bool forceImagePyramidOutput) {
createInputPort<DataObject>(0); // Can be Image, Batch or Tensor
createOutputPort<DataObject>(0); // Can be Image or Tensor

createOpenCLProgram(Config::getKernelSourcePath() + "/Algorithms/ImagePatch/PatchStitcher2D.cl", "2D");
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() {
Expand Down Expand Up @@ -122,7 +123,7 @@ void PatchStitcher::processImage(std::shared_ptr<Image> 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 {
Expand Down Expand Up @@ -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;
}


}
17 changes: 16 additions & 1 deletion source/FAST/Algorithms/ImagePatch/PatchStitcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand All @@ -52,6 +66,7 @@ class FAST_EXPORT PatchStitcher : public ProcessObject {
void processImage(std::shared_ptr<Image> tensor);
private:
bool m_patchesAreCropped = false;
bool m_forceImagePyramidOutput = false;

};

Expand Down

0 comments on commit f447f9a

Please sign in to comment.