18 #ifndef __otbSFSTexturesImageFilter_txx
19 #define __otbSFSTexturesImageFilter_txx
31 template <
class TInputImage,
class TOutputImage>
35 this->SetNumberOfInputs(1);
36 this->SetNumberOfRequiredInputs(1);
37 this->SetNumberOfOutputs(6);
38 this->SetNumberOfRequiredOutputs(1);
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());
47 m_Radius = this->GetSpatialThreshold();
48 m_FunctorList.clear();
57 template <
class TInputImage,
class TOutputImage>
62 if (this->GetNumberOfOutputs() < 1)
66 if (this->GetTexturesStatus()[0] ==
false)
68 itkExceptionMacro(<<
"Impossible to create length image : texture not selected");
72 template <
class TInputImage,
class TOutputImage>
77 if (this->GetNumberOfOutputs() < 1)
81 if (this->GetTexturesStatus()[0] ==
false)
83 itkExceptionMacro(<<
"Impossible to create length image : texture not selected");
89 template <
class TInputImage,
class TOutputImage>
94 if (this->GetNumberOfOutputs() < 2)
98 if (this->GetTexturesStatus()[1] ==
false)
100 itkExceptionMacro(<<
"Impossible to create width image : texture not selected");
104 template <
class TInputImage,
class TOutputImage>
109 if (this->GetNumberOfOutputs() < 2)
113 if (this->GetTexturesStatus()[1] ==
false)
115 itkExceptionMacro(<<
"Impossible to create width image : texture not selected");
121 template <
class TInputImage,
class TOutputImage>
126 if (this->GetNumberOfOutputs() < 3)
130 if (this->GetTexturesStatus()[2] ==
false)
132 itkExceptionMacro(<<
"Impossible to create PSI image : texture not selected");
136 template <
class TInputImage,
class TOutputImage>
141 if (this->GetNumberOfOutputs() < 3)
145 if (this->GetTexturesStatus()[2] ==
false)
147 itkExceptionMacro(<<
"Impossible to create PSI image : texture not selected");
154 template <
class TInputImage,
class TOutputImage>
159 if (this->GetNumberOfOutputs() < 4)
163 if (this->GetTexturesStatus()[3] ==
false)
165 itkExceptionMacro(<<
"Impossible to create W-Mean image : texture not selected");
169 template <
class TInputImage,
class TOutputImage>
174 if (this->GetNumberOfOutputs() < 4)
178 if (this->GetTexturesStatus()[3] ==
false)
180 itkExceptionMacro(<<
"Impossible to create W-Mean image : texture not selected");
186 template <
class TInputImage,
class TOutputImage>
191 if (this->GetNumberOfOutputs() < 5)
195 if (this->GetTexturesStatus()[4] ==
false)
197 itkExceptionMacro(<<
"Impossible to create Ratio image : texture not selected");
201 template <
class TInputImage,
class TOutputImage>
206 if (this->GetNumberOfOutputs() < 5)
210 if (this->GetTexturesStatus()[4] ==
false)
212 itkExceptionMacro(<<
"Impossible to create Ratio image : texture not selected");
218 template <
class TInputImage,
class TOutputImage>
223 if (this->GetNumberOfOutputs() < 6)
227 if (this->GetTexturesStatus()[5] ==
false)
229 itkExceptionMacro(<<
"Impossible to create SD image : texture not selected");
233 template <
class TInputImage,
class TOutputImage>
238 if (this->GetNumberOfOutputs() < 6)
242 if (this->GetTexturesStatus()[5] ==
false)
244 itkExceptionMacro(<<
"Impossible to create SD image : texture not selected");
250 template <
class TInputImage,
class TOutputImage>
255 Superclass::BeforeThreadedGenerateData();
256 if (this->GetSpatialThreshold() < this->GetRatioMaxConsiderationNumber())
258 itkExceptionMacro(<<
"Spatial Threshold (" << this->GetSpatialThreshold()
259 <<
") is lower than Ration Max Consideration Number ("
260 << this->GetRatioMaxConsiderationNumber() <<
") what is not allowed.");
262 for (
int i = 0; i < this->GetNumberOfThreads(); ++i)
264 m_FunctorList.push_back(m_Functor);
266 this->InitFeatureStatus(
true);
269 template <
class TInputImage,
class TOutputImage>
275 Superclass::GenerateInputRequestedRegion();
286 if (!inputPtr || !outputPtr1 || !outputPtr2 || !outputPtr3 || !outputPtr4 || !outputPtr5 || !outputPtr6)
292 typename TInputImage::RegionType inputRequestedRegion;
293 inputRequestedRegion = inputPtr->GetRequestedRegion();
299 inputRequestedRegion.PadByRadius(rad);
302 if (inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()))
304 inputPtr->SetRequestedRegion(inputRequestedRegion);
313 inputPtr->SetRequestedRegion(inputRequestedRegion);
317 std::ostringstream msg;
318 msg << this->GetNameOfClass()
319 <<
"::GenerateInputRequestedRegion()";
321 e.
SetDescription(
"Requested region is (at least partially) outside the largest possible region.");
327 template <
class TInputImage,
class TOutputImage>
332 Superclass::GenerateOutputInformation();
336 template <
class TInputImage,
class TOutputImage>
355 r.
Fill(this->GetRadius());
364 faceList = bC(inputPtr, outputRegionForThread, r);
374 std::vector<bool> textStatus = this->GetTexturesStatus();
375 for (fit = faceList.begin(); fit != faceList.end(); ++fit)
386 std::vector<itk::ImageRegionIterator<TOutputImage> *> outItList;
387 outItList.push_back(&outputIt1);
388 outItList.push_back(&outputIt2);
389 outItList.push_back(&outputIt3);
390 outItList.push_back(&outputIt4);
391 outItList.push_back(&outputIt5);
392 outItList.push_back(&outputIt6);
397 for (
unsigned int i = 0; i < outItList.size(); ++i)
399 (*outItList[i]).GoToBegin();
405 outputFunctor = m_FunctorList[threadId](neighInputIt);
406 for (
unsigned int i = 0; i < outItList.size(); ++i)
408 if (textStatus[i] ==
true) (*outItList[i]).Set(outputFunctor[i]);
412 for (
unsigned int i = 0; i < outItList.size(); ++i)
417 progress.CompletedPixel();
422 template <
class TInputImage,
class TOutputImage>
430 this->SetFeatureStatus(static_cast<FeatureType>(
id), status);
437 template <
class TInputImage,
class TOutputImage>
442 Superclass::PrintSelf(os, indent);