18 #ifndef __otbScalarImageToPanTexTextureFilter_txx
19 #define __otbScalarImageToPanTexTextureFilter_txx
28 template <
class TInputImage,
class TOutputImage>
31 m_NumberOfBinsPerAxis(8),
32 m_InputImageMinimum(0),
33 m_InputImageMaximum(256)
36 this->SetNumberOfOutputs(1);
42 m_OffsetList.push_back(off);
44 m_OffsetList.push_back(off);
47 m_OffsetList.push_back(off);
49 m_OffsetList.push_back(off);
51 m_OffsetList.push_back(off);
53 m_OffsetList.push_back(off);
55 m_OffsetList.push_back(off);
58 m_OffsetList.push_back(off);
60 m_OffsetList.push_back(off);
62 m_OffsetList.push_back(off);
65 template <
class TInputImage,
class TOutputImage>
70 template <
class TInputImage,
class TOutputImage>
76 Superclass::GenerateInputRequestedRegion();
82 if (!inputPtr || !outputPtr)
99 inputRequestedRegion.PadByRadius(m_Radius + maxOffsetSize);
102 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
104 inputPtr->SetRequestedRegion(inputRequestedRegion);
111 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
117 template <
class TInputImage,
class TOutputImage>
139 typename InputRegionType::IndexType currentIndex = outputIt.
GetIndex() - m_Radius;
140 typename InputRegionType::SizeType currentSize;
142 for (
unsigned int dim = 0; dim < InputImageType::ImageDimension; ++dim)
145 currentSize[dim] = 2 * m_Radius[dim] + 1;
149 currentRegion.SetIndex(currentIndex);
150 currentRegion.SetSize(currentSize);
153 double out = itk::NumericTraits<double>::max();
156 typename OffsetListType::const_iterator offIt;
157 for (offIt = m_OffsetList.begin(); offIt != m_OffsetList.end(); ++offIt)
161 coOccurenceMatrixGenerator->SetInput(inputPtr);
162 coOccurenceMatrixGenerator->SetOffset((*offIt));
163 coOccurenceMatrixGenerator->SetNumberOfBinsPerAxis(m_NumberOfBinsPerAxis);
164 coOccurenceMatrixGenerator->SetPixelValueMinMax(m_InputImageMinimum, m_InputImageMaximum);
167 coOccurenceMatrixGenerator->SetRegion(currentRegion);
168 coOccurenceMatrixGenerator->SetNormalize(
true);
169 coOccurenceMatrixGenerator->Compute();
181 typename InputRegionType::IndexType index = histo->GetIndex(hit.GetInstanceIdentifier());
182 inertia += (index[0] - index[1]) * (index[0] - index[1]) * frequency;
185 if (inertia < out) out = inertia;
190 progress.CompletedPixel();