Skip to content

Commit

Permalink
Fixed bug in PatchStitcher with the new change in PatchGenerator wher…
Browse files Browse the repository at this point in the history
…e also patches generated from Image objects are padded if needed.
  • Loading branch information
smistad committed Aug 14, 2023
1 parent 62c53fc commit 551bb71
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions source/FAST/Algorithms/ImagePatch/PatchStitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,29 @@ void PatchStitcher::processImage(std::shared_ptr<Image> patch) {
reportInfo() << "Stitching " << startZ << reportEnd();
auto patchAccess = patch->getOpenCLImageAccess(ACCESS_READ, device);

int patchWidth = patch->getWidth();
if (startX + patchWidth > fullWidth)
patchWidth = fullWidth - startX;
int patchHeight = patch->getHeight();
if (startY + patchHeight > fullHeight)
patchHeight = fullHeight - startY;
int patchDepth = patch->getDepth();
if (startZ + patchDepth > fullDepth)
patchDepth = fullDepth - startZ;

if(device->isWritingTo3DTexturesSupported()) {
auto outputAccess = m_outputImage->getOpenCLImageAccess(ACCESS_READ_WRITE, device);
cl::Program program = getOpenCLProgram(device, "3D");
cl::Kernel kernel;
cl::NDRange size;
if(patch->getDimensions() == 2) {
kernel = cl::Kernel(program, "applyPatch2Dto3D");
size = cl::NDRange(patch->getWidth(), patch->getHeight());
kernel.setArg(0, *patchAccess->get3DImage());
size = cl::NDRange(patchWidth, patchHeight);
kernel.setArg(0, *patchAccess->get2DImage());
} else {
kernel = cl::Kernel(program, "applyPatch3D");
size =
kernel.setArg(0, *patchAccess->get2DImage());
size = cl::NDRange(patchWidth, patchHeight, patchDepth);
kernel.setArg(0, *patchAccess->get3DImage());
}
kernel.setArg(2, startX);
kernel.setArg(3, startY);
Expand All @@ -260,12 +270,12 @@ void PatchStitcher::processImage(std::shared_ptr<Image> patch) {
cl::NDRange size;
if(patch->getDimensions() == 2) {
kernel = cl::Kernel(program, "applyPatch2Dto3D");
size = cl::NDRange(patch->getWidth(), patch->getHeight());
kernel.setArg(0, *patchAccess->get3DImage());
size = cl::NDRange(patchWidth, patchHeight);
kernel.setArg(0, *patchAccess->get2DImage());
} else {
kernel = cl::Kernel(program, "applyPatch3D");
size = cl::NDRange(patch->getWidth(), patch->getHeight(), patch->getDepth());
kernel.setArg(0, *patchAccess->get2DImage());
size = cl::NDRange(patchWidth, patchHeight, patchDepth);
kernel.setArg(0, *patchAccess->get3DImage());
}
kernel.setArg(1, *outputAccess->get());
kernel.setArg(2, startX);
Expand Down

0 comments on commit 551bb71

Please sign in to comment.