21 #ifndef otbSFSTexturesFunctor_h
22 #define otbSFSTexturesFunctor_h
25 #include "itkNumericTraits.h"
58 template <
class TIter,
class TOutputValue>
120 itkGetMacro(SpatialThreshold,
unsigned int);
122 itkGetMacro(RatioMaxConsiderationNumber,
unsigned int);
123 itkGetMacro(Alpha,
double);
124 itkGetMacro(NumberOfDirections,
unsigned int);
133 double length = itk::NumericTraits<double>::NonpositiveMin();
134 double width = itk::NumericTraits<double>::max();
140 double sumWMean = 0.;
148 std::vector<double>::iterator itVector;
160 off[0] =
static_cast<int>(std::floor(SpatialThresholdDouble * std::cos(angle) + 0.5));
161 off[1] =
static_cast<int>(std::floor(SpatialThresholdDouble * std::sin(angle) + 0.5));
171 dist = std::sqrt(std::pow(
static_cast<double>(offEnd[0] - offStart[0]), 2) + std::pow(
static_cast<double>(offEnd[1] - offStart[1]), 2));
195 itVector = maxSorted.begin();
196 while (itVector != maxSorted.end() && doo ==
false)
198 if (dist > (*itVector))
200 itVector = maxSorted.insert(itVector, dist);
201 maxSorted.pop_back();
207 itVector = minSorted.begin();
208 while (itVector != minSorted.end() && doo ==
false)
210 if (dist < (*itVector))
212 itVector = minSorted.insert(itVector, dist);
213 minSorted.pop_back();
223 lengthLine[d] =
static_cast<unsigned int>(
227 sumWMean += (
m_Alpha * (dist - 1) * dist ) / sdiVal;
243 out[3] =
static_cast<OutputValueType>(sumWMean / NumberOfDirectionsDouble);
251 sumMin += minSorted[t];
252 sumMax += maxSorted[t];
256 else if (sumMax == 0. && sumMin == 0.)
263 for (
unsigned int n = 0; n < di.size(); ++n)
264 sumPSI += std::pow(di[n] - sumWMean / NumberOfDirectionsDouble, 2);
265 out[5] =
static_cast<OutputValueType>(std::sqrt(sumPSI) / (NumberOfDirectionsDouble - 1.));
284 currentOff[0] = signX;
287 if (stopOffset[0] != 0)
288 slop =
static_cast<double>(stopOffset[1] /
static_cast<double>(stopOffset[0]));
290 bool isInside =
true;
291 while (isInside ==
true && res ==
true)
300 currentOff[0] += signX;
302 isInside = this->
CheckIsInside(signX, signY, currentOff, stopOffset);
312 unsigned int nbElt = 0;
316 if (stopOffset[0] != 0)
317 slop =
static_cast<double>(stopOffset[1] /
static_cast<double>(stopOffset[0]));
325 currentOff[0] = signX;
327 bool isInside =
true;
329 while (isInside ==
true && canGo ==
true)
333 mean +=
static_cast<double>(it.GetPixel(currentOff));
339 currentOff[0] += signX;
341 isInside = this->
CheckIsInside(signX, signY, currentOff, stopOffset);
344 mean /=
static_cast<double>(nbElt);
345 currentOff[0] = signX;
349 while (isInside ==
true && canGo ==
true)
353 SDi += std::pow((
static_cast<double>(it.GetPixel(currentOff)) -
mean), 2);
357 currentOff[0] += signX;
359 isInside = this->
CheckIsInside(signX, signY, currentOff, stopOffset);
361 return std::sqrt(SDi);
367 bool isInside =
true;
368 if (signX * currentOff[0] >= signX * stopOffset[0] && stopOffset[0] != 0)
370 else if (signY * currentOff[1] >= signY * stopOffset[1] && stopOffset[1] != 0)
383 if (stopOffsetX != 0)
384 currentOff[1] =
static_cast<int>(std::floor(slop *
static_cast<double>(currentOff[0]) + 0.5));
386 currentOff[1] += signY;