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>
49 const unsigned int nbOfUsedInputImages = Superclass::GetNumberOfUsedInputImages();
52 const unsigned int nBands = Superclass::GetNumberOfBands();
55 IteratorType outputIt(mosaicImage, outputRegionForThread);
58 typename std::vector<InputImageType*> currentImage;
59 typename std::vector<InterpolatorPointerType> interp;
60 Superclass::PrepareImageAccessors(currentImage, interp);
63 typename std::vector<DistanceImageType*> currentDistanceImage;
64 typename std::vector<DistanceImageInterpolatorPointer> distanceInterpolator;
65 Superclass::PrepareDistanceImageAccessors(currentDistanceImage, distanceInterpolator);
69 interpolatedMathPixel.SetSize(nBands);
70 tempOutputPixel.SetSize(nBands);
74 bool isDataInCurrentOutputPixel;
81 for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt)
84 mosaicImage->TransformIndexToPhysicalPoint(outputIt.GetIndex(), geoPoint);
87 isDataInCurrentOutputPixel =
false;
90 tempOutputPixel.Fill(0.0);
93 for (i = 0; i < nbOfUsedInputImages; i++)
99 if (interp[i]->IsInsideBuffer(geoPoint))
103 interpolatedPixel = interp[i]->Evaluate(geoPoint);
106 if (Superclass::IsPixelNotEmpty(interpolatedPixel))
111 if (distanceInterpolator[i]->IsInsideBuffer(geoPoint))
113 distanceImagePixel = distanceInterpolator[i]->Evaluate(geoPoint);
114 distanceImagePixel -= Superclass::GetDistanceOffset();
118 if (distanceImagePixel > 0 || !isDataInCurrentOutputPixel)
123 if (distanceImagePixel < m_FeatheringTransitionDistance && isDataInCurrentOutputPixel)
126 coef1 = distanceImagePixel / m_FeatheringTransitionDistance;
127 coef1 = vcl_pow(coef1, m_FeatheringSmoothness);
138 const unsigned int inputImageIndex = Superclass::GetUsedInputImageIndice(i);
139 for (band = 0; band < nBands; band++)
142 interpolatedMathPixel[band] =
static_cast<InternalValueType>(interpolatedPixel[band]);
145 if (this->GetShiftScaleInputImages())
147 this->ShiftScaleValue(interpolatedMathPixel[band], inputImageIndex, band);
151 tempOutputPixel[band] = coef1 * interpolatedMathPixel[band] + coef2 * tempOutputPixel[band];
156 isDataInCurrentOutputPixel =
true;
164 itkWarningMacro(<<
"Unable to evaluate distance at point " << geoPoint);
165 distanceImagePixel = 0;
175 if (isDataInCurrentOutputPixel)
179 for (band = 0; band < nBands; band++)
183 pixelValue = tempOutputPixel[band];
184 Superclass::NormalizePixelValue(pixelValue);
191 outputIt.Set(outputPixel);
Superclass::InternalPixelType InternalPixelType
Superclass::OutputImagePixelType OutputImagePixelType
Superclass::OutputImagePointType OutputImagePointType
Superclass::OutputImageInternalPixelType OutputImageInternalPixelType
Superclass::IteratorType IteratorType
Superclass::OutputImageType OutputImageType
Superclass::InternalValueType InternalValueType
Superclass::InputImagePixelType InputImagePixelType
Superclass::OutputImageRegionType OutputImageRegionType
StreamingFeatherMosaicFilter()
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.