21 #ifndef otbPixelWiseBlockMatchingImageFilter_hxx
22 #define otbPixelWiseBlockMatchingImageFilter_hxx
25 #include "itkProgressReporter.h"
26 #include "itkConstantBoundaryCondition.h"
30 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
31 PixelWiseBlockMatchingImageFilter<TInputImage, TOutputMetricImage, TOutputDisparityImage, TMaskImage,
35 this->SetNumberOfRequiredInputs(6);
36 this->SetNumberOfRequiredInputs(2);
39 this->SetNumberOfRequiredOutputs(3);
40 this->SetNthOutput(0, TOutputMetricImage::New());
41 this->SetNthOutput(1, TOutputDisparityImage::New());
42 this->SetNthOutput(2, TOutputDisparityImage::New());
51 m_MinimumHorizontalDisparity = -10;
52 m_MaximumHorizontalDisparity = 10;
53 m_MinimumVerticalDisparity = 0;
54 m_MaximumVerticalDisparity = 0;
57 m_InitHorizontalDisparity = 0;
58 m_InitVerticalDisparity = 0;
61 m_ExplorationRadius.Fill(0);
72 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
74 TBlockMatchingFunctor>::~PixelWiseBlockMatchingImageFilter()
79 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
81 const TInputImage* image)
84 this->SetNthInput(0,
const_cast<TInputImage*
>(image));
87 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
89 const TInputImage* image)
92 this->SetNthInput(1,
const_cast<TInputImage*
>(image));
95 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
97 const TMaskImage* image)
100 this->SetNthInput(2,
const_cast<TMaskImage*
>(image));
103 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
105 const TMaskImage* image)
108 this->SetNthInput(3,
const_cast<TMaskImage*
>(image));
111 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
115 if (this->GetNumberOfInputs() < 1)
119 return static_cast<const TInputImage*
>(this->itk::ProcessObject::GetInput(0));
122 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
126 if (this->GetNumberOfInputs() < 2)
130 return static_cast<const TInputImage*
>(this->itk::ProcessObject::GetInput(1));
133 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
137 if (this->GetNumberOfInputs() < 3)
141 return static_cast<const TMaskImage*
>(this->itk::ProcessObject::GetInput(2));
144 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
148 if (this->GetNumberOfInputs() < 4)
152 return static_cast<const TMaskImage*
>(this->itk::ProcessObject::GetInput(3));
155 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
156 const TOutputMetricImage*
159 if (this->GetNumberOfOutputs() < 1)
163 return static_cast<const TOutputMetricImage*
>(this->itk::ProcessObject::GetOutput(0));
166 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
170 if (this->GetNumberOfOutputs() < 1)
174 return static_cast<TOutputMetricImage*
>(this->itk::ProcessObject::GetOutput(0));
178 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
179 const TOutputDisparityImage* PixelWiseBlockMatchingImageFilter<TInputImage, TOutputMetricImage, TOutputDisparityImage, TMaskImage,
180 TBlockMatchingFunctor>::GetHorizontalDisparityOutput()
const
182 if (this->GetNumberOfOutputs() < 2)
186 return static_cast<const TOutputDisparityImage*
>(this->itk::ProcessObject::GetOutput(1));
189 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
190 TOutputDisparityImage*
193 if (this->GetNumberOfOutputs() < 2)
197 return static_cast<TOutputDisparityImage*
>(this->itk::ProcessObject::GetOutput(1));
200 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
201 const TOutputDisparityImage*
204 if (this->GetNumberOfOutputs() < 3)
208 return static_cast<const TOutputDisparityImage*
>(this->itk::ProcessObject::GetOutput(2));
211 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
212 TOutputDisparityImage*
215 if (this->GetNumberOfOutputs() < 3)
219 return static_cast<TOutputDisparityImage*
>(this->itk::ProcessObject::GetOutput(2));
222 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
224 const TOutputDisparityImage* hfield)
227 this->SetNthInput(4,
const_cast<TOutputDisparityImage*
>(hfield));
230 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
232 const TOutputDisparityImage* vfield)
235 this->SetNthInput(5,
const_cast<TOutputDisparityImage*
>(vfield));
238 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
240 TBlockMatchingFunctor>::GetHorizontalDisparityInput()
const
242 if (this->GetNumberOfInputs() < 5)
246 return static_cast<const TOutputDisparityImage*
>(this->itk::ProcessObject::GetInput(4));
249 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
250 const TOutputDisparityImage*
253 if (this->GetNumberOfInputs() < 6)
257 return static_cast<const TOutputDisparityImage*
>(this->itk::ProcessObject::GetInput(5));
260 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
264 Superclass::GenerateOutputInformation();
267 if (this->m_Step == 0)
269 this->m_GridIndex[0] = this->m_GridIndex[0] % this->m_Step;
270 this->m_GridIndex[1] = this->m_GridIndex[1] % this->m_Step;
273 const TInputImage* inLeftPtr = this->GetLeftInput();
275 RegionType outputLargest = this->ConvertFullToSubsampledRegion(inLeftPtr->GetLargestPossibleRegion(), this->m_Step, this->m_GridIndex);
277 TOutputMetricImage* outMetricPtr =
const_cast<TOutputMetricImage*
>(this->GetMetricOutput());
278 TOutputDisparityImage* outHDispPtr =
const_cast<TOutputDisparityImage*
>(this->GetHorizontalDisparityOutput());
279 TOutputDisparityImage* outVDispPtr =
const_cast<TOutputDisparityImage*
>(this->GetVerticalDisparityOutput());
281 outMetricPtr->SetLargestPossibleRegion(outputLargest);
282 outHDispPtr->SetLargestPossibleRegion(outputLargest);
283 outVDispPtr->SetLargestPossibleRegion(outputLargest);
286 SpacingType outSpacing = inLeftPtr->GetSignedSpacing();
287 outSpacing[0] *=
static_cast<double>(this->m_Step);
288 outSpacing[1] *=
static_cast<double>(this->m_Step);
290 outMetricPtr->SetSignedSpacing(outSpacing);
291 outHDispPtr->SetSignedSpacing(outSpacing);
292 outVDispPtr->SetSignedSpacing(outSpacing);
295 PointType outOrigin = inLeftPtr->GetOrigin();
296 SpacingType inSpacing = inLeftPtr->GetSignedSpacing();
297 outOrigin[0] += inSpacing[0] *
static_cast<double>(this->m_GridIndex[0]);
298 outOrigin[1] += inSpacing[1] *
static_cast<double>(this->m_GridIndex[1]);
300 outMetricPtr->SetOrigin(outOrigin);
301 outHDispPtr->SetOrigin(outOrigin);
302 outVDispPtr->SetOrigin(outOrigin);
305 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
307 TBlockMatchingFunctor>::GenerateInputRequestedRegion()
310 Superclass::GenerateInputRequestedRegion();
313 TInputImage* inLeftPtr =
const_cast<TInputImage*
>(this->GetLeftInput());
314 TInputImage* inRightPtr =
const_cast<TInputImage*
>(this->GetRightInput());
315 TMaskImage* inLeftMaskPtr =
const_cast<TMaskImage*
>(this->GetLeftMaskInput());
316 TMaskImage* inRightMaskPtr =
const_cast<TMaskImage*
>(this->GetRightMaskInput());
317 TOutputDisparityImage* inHDispPtr =
const_cast<TOutputDisparityImage*
>(this->GetHorizontalDisparityInput());
318 TOutputDisparityImage* inVDispPtr =
const_cast<TOutputDisparityImage*
>(this->GetVerticalDisparityInput());
320 TOutputMetricImage* outMetricPtr = this->GetMetricOutput();
321 TOutputDisparityImage* outHDispPtr = this->GetHorizontalDisparityOutput();
322 TOutputDisparityImage* outVDispPtr = this->GetVerticalDisparityOutput();
325 if (!inLeftPtr || !inRightPtr || !outMetricPtr || !outHDispPtr || !outVDispPtr)
331 if (inLeftPtr->GetLargestPossibleRegion() != inRightPtr->GetLargestPossibleRegion())
333 itkExceptionMacro(<<
"Left and right images do not have the same size ! Left largest region: " << inLeftPtr->GetLargestPossibleRegion()
334 <<
", right largest region: " << inRightPtr->GetLargestPossibleRegion());
338 if (inLeftMaskPtr && inLeftPtr->GetLargestPossibleRegion() != inLeftMaskPtr->GetLargestPossibleRegion())
340 itkExceptionMacro(<<
"Left and mask images do not have the same size ! Left largest region: " << inLeftPtr->GetLargestPossibleRegion()
341 <<
", mask largest region: " << inLeftMaskPtr->GetLargestPossibleRegion());
345 if (inRightMaskPtr && inRightPtr->GetLargestPossibleRegion() != inRightMaskPtr->GetLargestPossibleRegion())
347 itkExceptionMacro(<<
"Right and mask images do not have the same size ! Right largest region: " << inRightPtr->GetLargestPossibleRegion()
348 <<
", mask largest region: " << inRightMaskPtr->GetLargestPossibleRegion());
352 if (inHDispPtr && inLeftPtr->GetLargestPossibleRegion() != inHDispPtr->GetLargestPossibleRegion())
354 itkExceptionMacro(<<
"Left image and initial horizontal disparity map do not have the same size ! Left largest region: "
355 << inLeftPtr->GetLargestPossibleRegion() <<
", horizontal disparity largest region: " << inHDispPtr->GetLargestPossibleRegion());
357 if (inVDispPtr && inLeftPtr->GetLargestPossibleRegion() != inVDispPtr->GetLargestPossibleRegion())
359 itkExceptionMacro(<<
"Left image and initial vertical disparity map do not have the same size ! Left largest region: "
360 << inLeftPtr->GetLargestPossibleRegion() <<
", vertical disparity largest region: " << inVDispPtr->GetLargestPossibleRegion());
364 if (this->m_Step == 0)
366 this->m_GridIndex[0] = this->m_GridIndex[0] % this->m_Step;
367 this->m_GridIndex[1] = this->m_GridIndex[1] % this->m_Step;
371 RegionType inputLeftRegion = this->ConvertSubsampledToFullRegion(outMetricPtr->GetRequestedRegion(), this->m_Step, this->m_GridIndex);
374 inputLeftRegion.PadByRadius(m_Radius);
377 IndexType rightRequestedRegionIndex = inputLeftRegion.GetIndex();
378 rightRequestedRegionIndex[0] += m_MinimumHorizontalDisparity;
379 rightRequestedRegionIndex[1] += m_MinimumVerticalDisparity;
381 SizeType rightRequestedRegionSize = inputLeftRegion.GetSize();
382 rightRequestedRegionSize[0] += m_MaximumHorizontalDisparity - m_MinimumHorizontalDisparity;
383 rightRequestedRegionSize[1] += m_MaximumVerticalDisparity - m_MinimumVerticalDisparity;
386 inputRightRegion.SetIndex(rightRequestedRegionIndex);
387 inputRightRegion.SetSize(rightRequestedRegionSize);
390 if (inputLeftRegion.Crop(inLeftPtr->GetLargestPossibleRegion()))
392 inLeftPtr->SetRequestedRegion(inputLeftRegion);
399 inLeftPtr->SetRequestedRegion(inputLeftRegion);
402 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
403 std::ostringstream msg;
404 msg << this->GetNameOfClass() <<
"::GenerateInputRequestedRegion()";
405 e.SetLocation(msg.str());
406 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region of left image.");
407 e.SetDataObject(inLeftPtr);
413 if (inputRightRegion.Crop(inRightPtr->GetLargestPossibleRegion()))
415 inRightPtr->SetRequestedRegion(inputRightRegion);
422 inRightPtr->SetRequestedRegion(inputRightRegion);
425 itk::InvalidRequestedRegionError e(__FILE__, __LINE__);
426 std::ostringstream msg;
427 msg << this->GetNameOfClass() <<
"::GenerateInputRequestedRegion()";
428 e.SetLocation(msg.str());
429 e.SetDescription(
"Requested region is (at least partially) outside the largest possible region of right image.");
430 e.SetDataObject(inRightPtr);
437 inLeftMaskPtr->SetRequestedRegion(inputLeftRegion);
443 inRightMaskPtr->SetRequestedRegion(inputRightRegion);
446 if (inHDispPtr && inVDispPtr)
448 inHDispPtr->SetRequestedRegion(inputLeftRegion);
449 inVDispPtr->SetRequestedRegion(inputLeftRegion);
452 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
455 TOutputMetricImage* outMetricPtr = this->GetMetricOutput();
456 TOutputDisparityImage* outHDispPtr = this->GetHorizontalDisparityOutput();
457 TOutputDisparityImage* outVDispPtr = this->GetVerticalDisparityOutput();
460 if (this->m_Step == 0)
462 this->m_GridIndex[0] = this->m_GridIndex[0] % this->m_Step;
463 this->m_GridIndex[1] = this->m_GridIndex[1] % this->m_Step;
466 outMetricPtr->FillBuffer(0.);
471 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
473 const RegionType& outputRegionForThread, itk::ThreadIdType threadId)
476 const TInputImage* inLeftPtr = this->GetLeftInput();
477 const TInputImage* inRightPtr = this->GetRightInput();
478 const TMaskImage* inLeftMaskPtr = this->GetLeftMaskInput();
479 const TMaskImage* inRightMaskPtr = this->GetRightMaskInput();
480 const TOutputDisparityImage* inHDispPtr = this->GetHorizontalDisparityInput();
481 const TOutputDisparityImage* inVDispPtr = this->GetVerticalDisparityInput();
482 TOutputMetricImage* outMetricPtr = this->GetMetricOutput();
483 TOutputDisparityImage* outHDispPtr = this->GetHorizontalDisparityOutput();
484 TOutputDisparityImage* outVDispPtr = this->GetVerticalDisparityOutput();
488 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels() * (m_MaximumHorizontalDisparity - m_MinimumHorizontalDisparity + 1) *
489 (m_MaximumVerticalDisparity - m_MinimumVerticalDisparity + 1),
494 typename InputMaskImageType::Pointer initMaskPtr = InputMaskImageType::New();
495 initMaskPtr->SetRegions(outputRegionForThread);
496 initMaskPtr->Allocate();
497 initMaskPtr->FillBuffer(0);
500 RegionType fullRegionForThread = this->ConvertSubsampledToFullRegion(outputRegionForThread, this->m_Step, this->m_GridIndex);
503 bool useExplorationRadius =
false;
504 bool useInitDispMaps =
false;
505 if (m_ExplorationRadius[0] >= 1 || m_ExplorationRadius[1] >= 1)
507 useExplorationRadius =
true;
508 if (inHDispPtr && inVDispPtr)
510 useInitDispMaps =
true;
518 for (
int vdisparity = m_MinimumVerticalDisparity; vdisparity <= m_MaximumVerticalDisparity; ++vdisparity)
520 for (
int hdisparity = m_MinimumHorizontalDisparity; hdisparity <= m_MaximumHorizontalDisparity; ++hdisparity)
523 IndexType rightRequestedRegionIndex = fullRegionForThread.GetIndex();
524 rightRequestedRegionIndex[0] += hdisparity;
525 rightRequestedRegionIndex[1] += vdisparity;
529 inputRightRegion.SetIndex(rightRequestedRegionIndex);
530 inputRightRegion.SetSize(fullRegionForThread.GetSize());
531 inputRightRegion.Crop(inRightPtr->GetLargestPossibleRegion());
534 IndexType leftRequestedRegionIndex = inputRightRegion.GetIndex();
535 leftRequestedRegionIndex[0] -= hdisparity;
536 leftRequestedRegionIndex[1] -= vdisparity;
539 inputLeftRegion.SetIndex(leftRequestedRegionIndex);
540 inputLeftRegion.SetSize(inputRightRegion.GetSize());
543 RegionType outputRegion = this->ConvertFullToSubsampledRegion(inputLeftRegion, this->m_Step, this->m_GridIndex);
546 itk::ConstNeighborhoodIterator<TInputImage> leftIt(m_Radius, inLeftPtr, inputLeftRegion);
547 itk::ConstNeighborhoodIterator<TInputImage> rightIt(m_Radius, inRightPtr, inputRightRegion);
548 itk::ImageRegionIterator<TOutputMetricImage> outMetricIt(outMetricPtr, outputRegion);
549 itk::ImageRegionIterator<TOutputDisparityImage> outHDispIt(outHDispPtr, outputRegion);
550 itk::ImageRegionIterator<TOutputDisparityImage> outVDispIt(outVDispPtr, outputRegion);
551 itk::ImageRegionConstIterator<TMaskImage> inLeftMaskIt;
552 itk::ImageRegionConstIterator<TMaskImage> inRightMaskIt;
553 itk::ImageRegionConstIterator<TOutputDisparityImage> inHDispIt;
554 itk::ImageRegionConstIterator<TOutputDisparityImage> inVDispIt;
555 itk::ImageRegionIterator<TMaskImage> initIt(initMaskPtr, outputRegion);
557 itk::ConstantBoundaryCondition<TInputImage> nbc1;
558 itk::ConstantBoundaryCondition<TInputImage> nbc2;
560 leftIt.OverrideBoundaryCondition(&nbc1);
561 rightIt.OverrideBoundaryCondition(&nbc2);
566 inLeftMaskIt = itk::ImageRegionConstIterator<TMaskImage>(inLeftMaskPtr, inputLeftRegion);
567 inLeftMaskIt.GoToBegin();
571 inRightMaskIt = itk::ImageRegionConstIterator<TMaskImage>(inRightMaskPtr, inputRightRegion);
572 inRightMaskIt.GoToBegin();
578 inHDispIt = itk::ImageRegionConstIterator<TOutputDisparityImage>(inHDispPtr, inputLeftRegion);
579 inVDispIt = itk::ImageRegionConstIterator<TOutputDisparityImage>(inVDispPtr, inputLeftRegion);
580 inHDispIt.GoToBegin();
581 inVDispIt.GoToBegin();
587 outMetricIt.GoToBegin();
588 outHDispIt.GoToBegin();
589 outVDispIt.GoToBegin();
593 while (!leftIt.IsAtEnd() || !rightIt.IsAtEnd() || !outMetricIt.IsAtEnd() || !outHDispIt.IsAtEnd() || !outVDispIt.IsAtEnd() || !initIt.IsAtEnd())
596 IndexType tmpIndex = leftIt.GetIndex(leftIt.GetCenterNeighborhoodIndex());
597 if (((tmpIndex[0] - this->m_GridIndex[0] + this->m_Step) % this->m_Step == 0) &&
598 ((tmpIndex[1] - this->m_GridIndex[1] + this->m_Step) % this->m_Step == 0))
601 if (!inLeftMaskPtr || (inLeftMaskIt.Get() > 0))
603 if (!inRightMaskPtr || (inRightMaskIt.Get() > 0))
605 int estimatedMinHDisp = m_MinimumHorizontalDisparity;
606 int estimatedMinVDisp = m_MinimumVerticalDisparity;
607 int estimatedMaxHDisp = m_MaximumHorizontalDisparity;
608 int estimatedMaxVDisp = m_MaximumVerticalDisparity;
609 if (useExplorationRadius)
614 estimatedMinHDisp = inHDispIt.Get() - m_ExplorationRadius[0];
615 estimatedMinVDisp = inVDispIt.Get() - m_ExplorationRadius[1];
616 estimatedMaxHDisp = inHDispIt.Get() + m_ExplorationRadius[0];
617 estimatedMaxVDisp = inVDispIt.Get() + m_ExplorationRadius[1];
621 estimatedMinHDisp = m_InitHorizontalDisparity - m_ExplorationRadius[0];
622 estimatedMinVDisp = m_InitVerticalDisparity - m_ExplorationRadius[1];
623 estimatedMaxHDisp = m_InitHorizontalDisparity + m_ExplorationRadius[0];
624 estimatedMaxVDisp = m_InitVerticalDisparity + m_ExplorationRadius[1];
627 if (estimatedMinHDisp < m_MinimumHorizontalDisparity)
629 estimatedMinHDisp = m_MinimumHorizontalDisparity;
631 if (estimatedMinVDisp < m_MinimumVerticalDisparity)
633 estimatedMinVDisp = m_MinimumVerticalDisparity;
637 if (vdisparity >= estimatedMinVDisp && vdisparity <= estimatedMaxVDisp && hdisparity >= estimatedMinHDisp && hdisparity <= estimatedMaxHDisp)
640 double metric = m_Functor(leftIt, rightIt);
644 if (initIt.Get() == 0)
648 outMetricIt.Set(metric);
651 else if (m_Minimize && metric < outMetricIt.Get())
655 outMetricIt.Set(metric);
657 else if (!m_Minimize && metric > outMetricIt.Get())
661 outMetricIt.Set(metric);
670 progress.CompletedPixel();
695 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
701 shiftedFull[0] -= index[0];
702 shiftedFull[1] -= index[1];
705 subIndex[0] = (shiftedFull[0]) / step;
706 subIndex[1] = (shiftedFull[1]) / step;
707 if (shiftedFull[0] % step)
709 if (shiftedFull[1] % step)
712 if (shiftedFull[0] < 0)
714 if (shiftedFull[1] < 0)
718 subSize[0] = (full.GetSize(0) - (subIndex[0] * step) + shiftedFull[0]) / step;
719 subSize[1] = (full.GetSize(1) - (subIndex[1] * step) + shiftedFull[1]) / step;
721 if ((full.GetSize(0) - (subIndex[0] * step) + shiftedFull[0]) % step)
723 if ((full.GetSize(1) - (subIndex[1] * step) + shiftedFull[1]) % step)
727 subRegion.SetIndex(subIndex);
728 subRegion.SetSize(subSize);
732 template <
class TInputImage,
class TOutputMetricImage,
class TOutputDisparityImage,
class TMaskImage,
class TBlockMatchingFunctor>
738 fullIndex[0] = sub.GetIndex(0) * step + index[0];
739 fullIndex[1] = sub.GetIndex(1) * step + index[1];
742 fullSize[0] = sub.GetSize(0) * step;
743 fullSize[1] = sub.GetSize(1) * step;
745 fullSize[0] -= (step - 1);
747 fullSize[1] -= (step - 1);
750 fullRegion.SetIndex(fullIndex);
751 fullRegion.SetSize(fullSize);