22 #ifndef __StreamingFeatherMosaicFilter_hxx
23 #define __StreamingFeatherMosaicFilter_hxx
30 template <
class TInputImage,
class TOutputImage,
class TDistanceImage,
class TInternalValueType>
33 m_FeatheringTransitionDistance = 500;
34 m_FeatheringSmoothness = 1.5;
40 template <
class TInputImage,
class TOutputImage,
class TDistanceImage,
class TInternalValueType>
46 itkDebugMacro(<<
"Actually executing thread " << threadId <<
" in region " << outputRegionForThread);
49 itk::ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
55 const unsigned int nbOfUsedInputImages = Superclass::GetNumberOfUsedInputImages();
58 const unsigned int nBands = Superclass::GetNumberOfBands();
61 IteratorType outputIt(mosaicImage, outputRegionForThread);
64 typename std::vector<InputImageType*> currentImage;
65 typename std::vector<InterpolatorPointerType> interp;
66 Superclass::PrepareImageAccessors(currentImage, interp);
69 typename std::vector<DistanceImageType*> currentDistanceImage;
70 typename std::vector<DistanceImageInterpolatorPointer> distanceInterpolator;
71 Superclass::PrepareDistanceImageAccessors(currentDistanceImage, distanceInterpolator);
75 interpolatedMathPixel.SetSize(nBands);
76 tempOutputPixel.SetSize(nBands);
80 bool isDataInCurrentOutputPixel;
87 for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt)
90 mosaicImage->TransformIndexToPhysicalPoint(outputIt.GetIndex(), geoPoint);
93 isDataInCurrentOutputPixel =
false;
96 tempOutputPixel.Fill(0.0);
99 for (i = 0; i < nbOfUsedInputImages; i++)
105 if (interp[i]->IsInsideBuffer(geoPoint))
109 interpolatedPixel = interp[i]->Evaluate(geoPoint);
112 if (Superclass::IsPixelNotEmpty(interpolatedPixel))
117 if (distanceInterpolator[i]->IsInsideBuffer(geoPoint))
119 distanceImagePixel = distanceInterpolator[i]->Evaluate(geoPoint);
120 distanceImagePixel -= Superclass::GetDistanceOffset();
124 if (distanceImagePixel > 0 || !isDataInCurrentOutputPixel)
129 if (distanceImagePixel < m_FeatheringTransitionDistance && isDataInCurrentOutputPixel)
132 coef1 = distanceImagePixel / m_FeatheringTransitionDistance;
133 coef1 = vcl_pow(coef1, m_FeatheringSmoothness);
144 const unsigned int inputImageIndex = Superclass::GetUsedInputImageIndice(i);
145 for (band = 0; band < nBands; band++)
148 interpolatedMathPixel[band] =
static_cast<InternalValueType>(interpolatedPixel[band]);
151 if (this->GetShiftScaleInputImages())
153 this->ShiftScaleValue(interpolatedMathPixel[band], inputImageIndex, band);
157 tempOutputPixel[band] = coef1 * interpolatedMathPixel[band] + coef2 * tempOutputPixel[band];
162 isDataInCurrentOutputPixel =
true;
170 itkWarningMacro(<<
"Unable to evaluate distance at point " << geoPoint);
171 distanceImagePixel = 0;
181 if (isDataInCurrentOutputPixel)
185 for (band = 0; band < nBands; band++)
189 pixelValue = tempOutputPixel[band];
190 Superclass::NormalizePixelValue(pixelValue);
197 outputIt.Set(outputPixel);
200 progress.CompletedPixel();