18 #ifndef __otbBinaryImageToDensityImageFilter_txx
19 #define __otbBinaryImageToDensityImageFilter_txx
32 template <
class TInputImage,
class TOutputImage,
class TCountFunction>
36 m_NeighborhoodRadius.Fill(1);
37 m_CountFunction = CountFunctionType::New();
41 template <
class TInputImage,
class TOutputImage,
class TCountFunction>
46 template <
class TInputImage,
class TOutputImage,
class TCountFunction>
52 Superclass::GenerateInputRequestedRegion();
58 if (!inputPtr || !outputPtr)
67 inputRequestedRegion.PadByRadius(m_NeighborhoodRadius);
70 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
72 inputPtr->SetRequestedRegion(inputRequestedRegion);
81 inputPtr->SetRequestedRegion(inputRequestedRegion);
85 std::ostringstream msg;
86 msg << this->GetNameOfClass()
87 <<
"::GenerateInputRequestedRegion()";
89 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
95 template <
class TInputImage,
class TOutputImage,
class TCountFunction>
100 Superclass::BeforeThreadedGenerateData();
102 m_CountFunction->SetInputImage(this->GetInput());
103 m_CountFunction->SetNeighborhoodRadius(m_NeighborhoodRadius);
107 template <
class TInputImage,
class TOutputImage,
class TCountFunction>
117 r[0] = m_NeighborhoodRadius[0];
118 r[1] = m_NeighborhoodRadius[1];
123 faceList = bC(inputPtr, outputRegionForThread, r);
130 typename InputImageType::IndexType index;
132 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
144 if (outputRegionForThread.IsInside(index))
146 itOut.Set(m_CountFunction->EvaluateAtIndex(index));
151 progress.CompletedPixel();
157 template <
class TInputImage,
class TOutputImage,
class TCountFunction>
162 Superclass::PrintSelf(os, indent);
163 os << indent <<
"Neighborhood Radius : " << m_NeighborhoodRadius << std::endl;