18 #ifndef __otbScalarImageToTexturesFilter_txx
19 #define __otbScalarImageToTexturesFilter_txx
28 template <
class TInputImage,
class TOutputImage>
32 m_NumberOfBinsPerAxis(8),
33 m_InputImageMinimum(0),
34 m_InputImageMaximum(256)
37 this->SetNumberOfOutputs(8);
40 this->SetNthOutput(0, OutputImageType::New());
41 this->SetNthOutput(1, OutputImageType::New());
42 this->SetNthOutput(2, OutputImageType::New());
43 this->SetNthOutput(3, OutputImageType::New());
44 this->SetNthOutput(4, OutputImageType::New());
45 this->SetNthOutput(5, OutputImageType::New());
46 this->SetNthOutput(6, OutputImageType::New());
47 this->SetNthOutput(7, OutputImageType::New());
50 template <
class TInputImage,
class TOutputImage>
55 template <
class TInputImage,
class TOutputImage>
61 if (this->GetNumberOfOutputs() < 1)
68 template <
class TInputImage,
class TOutputImage>
74 if (this->GetNumberOfOutputs() < 2)
81 template <
class TInputImage,
class TOutputImage>
87 if (this->GetNumberOfOutputs() < 3)
94 template <
class TInputImage,
class TOutputImage>
100 if (this->GetNumberOfOutputs() < 4)
107 template <
class TInputImage,
class TOutputImage>
113 if (this->GetNumberOfOutputs() < 5)
120 template <
class TInputImage,
class TOutputImage>
126 if (this->GetNumberOfOutputs() < 6)
133 template <
class TInputImage,
class TOutputImage>
139 if (this->GetNumberOfOutputs() < 7)
146 template <
class TInputImage,
class TOutputImage>
152 if (this->GetNumberOfOutputs() < 8)
159 template <
class TInputImage,
class TOutputImage>
165 Superclass::GenerateInputRequestedRegion();
171 if (!inputPtr || !outputPtr)
181 typename OutputRegionType::IndexType outputIndex = outputRequestedRegion.GetIndex();
182 typename OutputRegionType::SizeType outputSize = outputRequestedRegion.GetSize();
183 typename InputRegionType::IndexType inputIndex;
184 typename InputRegionType::SizeType inputSize;
187 for (
unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim)
189 inputIndex[dim] = std::min(outputIndex[dim], outputIndex[dim] + m_Offset[dim]);
191 std::max(outputIndex[dim] + outputSize[dim], outputIndex[dim] + outputSize[dim] +
192 m_Offset[dim]) - inputIndex[dim];
197 inputRequestedRegion.SetIndex(inputIndex);
198 inputRequestedRegion.SetSize(inputSize);
201 inputRequestedRegion.PadByRadius(m_Radius);
204 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
206 inputPtr->SetRequestedRegion(inputRequestedRegion);
213 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
219 template <
class TInputImage,
class TOutputImage>
257 coOccurenceMatrixGenerator->SetInput(inputPtr);
258 coOccurenceMatrixGenerator->SetOffset(m_Offset);
259 coOccurenceMatrixGenerator->SetNumberOfBinsPerAxis(m_NumberOfBinsPerAxis);
260 coOccurenceMatrixGenerator->SetPixelValueMinMax(m_InputImageMinimum, m_InputImageMaximum);
275 && !clusterProminenceIt.
IsAtEnd()
279 typename InputRegionType::IndexType inputIndex = energyIt.
GetIndex() - m_Radius;
280 typename InputRegionType::SizeType inputSize;
283 for (
unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim)
285 inputSize[dim] = 2 * m_Radius[dim] + 1;
290 inputRegion.SetIndex(inputIndex);
291 inputRegion.SetSize(inputSize);
294 coOccurenceMatrixGenerator->SetRegion(inputRegion);
295 coOccurenceMatrixGenerator->SetNormalize(
true);
296 coOccurenceMatrixGenerator->Compute();
299 texturesCalculator->SetHistogram(coOccurenceMatrixGenerator->GetOutput());
300 texturesCalculator->Compute();
303 energyIt.
Set(texturesCalculator->GetEnergy());
304 entropyIt.
Set(texturesCalculator->GetEntropy());
305 correlationIt.
Set(texturesCalculator->GetCorrelation());
306 invDiffMomentIt.
Set(texturesCalculator->GetInverseDifferenceMoment());
307 inertiaIt.
Set(texturesCalculator->GetInertia());
308 clusterShadeIt.
Set(texturesCalculator->GetClusterShade());
309 clusterProminenceIt.
Set(texturesCalculator->GetClusterProminence());
310 haralickCorIt.
Set(texturesCalculator->GetHaralickCorrelation());
313 progress.CompletedPixel();
322 ++clusterProminenceIt;