diff --git a/Modules/Applications/AppTextures/app/otbPantexTextureExtraction.cxx b/Modules/Applications/AppTextures/app/otbPantexTextureExtraction.cxx index 5e52292272525cf9867397681660d87f0084d07e..8b5363e97853ed3fb38e33ac1cd0e191622d67d3 100644 --- a/Modules/Applications/AppTextures/app/otbPantexTextureExtraction.cxx +++ b/Modules/Applications/AppTextures/app/otbPantexTextureExtraction.cxx @@ -57,7 +57,7 @@ private: SetDocLongDescription( "This application computes a texture-derived built-up presence index (PanTex) from textural" - "characteristics of scalar images. It is the min value of the contrast in 8 directions." + "characteristics of scalar images. This index is the min value of the contrast in 8 directions." ); SetDocLimitations("None"); diff --git a/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h b/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h index 4638058c2bdd62e01e2ca71c4ad7e3a6b35e6658..b2b72dfbed4af01ff0b8570526d97622caa472d0 100644 --- a/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h +++ b/Modules/Feature/Textures/include/otbGreyLevelCooccurrenceIndexedList.h @@ -41,7 +41,7 @@ namespace otb * iteration over the given input image. This class keep an internal itk::Array * as a lookup array with size as [nbbins x nbbins]. The lookup array stores * position CooccurrencePairType in the VectorType. It ensures us that all elements -* in Vector are unqiue in terms of the index value in the pair. For any given +* in Vector are unique in terms of the index value in the pair. For any given * pixel index, -1 value indicates zero existence of the index in the * VectorType. This avoid searching all elements in VectorType for each pixel * index added during neighborhood iterator. It is also used to decide wheather @@ -136,9 +136,7 @@ public: protected: GreyLevelCooccurrenceIndexedList(); - ~GreyLevelCooccurrenceIndexedList() override - { - } + ~GreyLevelCooccurrenceIndexedList() override = default; /** create a cooccurrence pair with given index and frequency = 1 * value. Next occurrence of same index is checked via m_LookupArray and the diff --git a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h index cbfebfba92b837b0c531c82db178514cebbcc5cb..0863e616ae32a206cba9eb3f3030f0a73fea1321 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h +++ b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.h @@ -113,7 +113,7 @@ protected: /** Constructor */ ScalarImageToPanTexTextureFilter(); /** Destructor */ - ~ScalarImageToPanTexTextureFilter() override; + ~ScalarImageToPanTexTextureFilter() override = default; /** Generate the input requested region */ void GenerateInputRequestedRegion() override; /** Parallel textures extraction */ diff --git a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx index 9a4457c0b78116818de1ebd0032ccfe5f7515273..93a2c826b348103b23827afbd8c95cf8be5c8e39 100644 --- a/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx +++ b/Modules/Feature/Textures/include/otbScalarImageToPanTexTextureFilter.hxx @@ -37,36 +37,9 @@ ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::ScalarImageToPanTex // There are 1 output corresponding to the Pan Tex texture indice this->SetNumberOfRequiredOutputs(1); - // Fill the offset list for contrast computation - OffsetType off; - off[0] = 0; - off[1] = 1; - m_OffsetList.push_back(off); //(0, 1) - off[1] = 2; - m_OffsetList.push_back(off); //(0, 2) - off[0] = 1; - off[1] = -2; - m_OffsetList.push_back(off); //(1, -2) - off[1] = -1; - m_OffsetList.push_back(off); //(1, -1) - off[1] = 0; - m_OffsetList.push_back(off); //(1, 0) - off[1] = 1; - m_OffsetList.push_back(off); //(1, 1) - off[1] = 2; - m_OffsetList.push_back(off); //(1, 2) - off[0] = 2; - off[1] = -1; - m_OffsetList.push_back(off); //(2, -1) - off[1] = 0; - m_OffsetList.push_back(off); //(2, 0) - off[1] = 1; - m_OffsetList.push_back(off); //(2, 1) -} - -template <class TInputImage, class TOutputImage> -ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::~ScalarImageToPanTexTextureFilter() -{ + // Ten offsets are selected for contrast computation (2 pixels displacement grid, and given that the + // co-occurance matrix is symmetric + m_OffsetList = { {0, 1}, {0, 2}, {1, -2}, {1, -1}, {1, 0}, {1, 1}, {1, 2}, {2, -1}, {2, 0}, {2, 1} }; } template <class TInputImage, class TOutputImage> @@ -93,9 +66,7 @@ void ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::GenerateInputR InputRegionType inputRequestedRegion = outputRequestedRegion; // Apply the radius - SizeType maxOffsetSize; - maxOffsetSize[0] = 2; - maxOffsetSize[1] = 2; + SizeType maxOffsetSize = {2, 2}; inputRequestedRegion.PadByRadius(m_Radius + maxOffsetSize); // Try to apply the requested region to the input image @@ -123,8 +94,6 @@ void ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::ThreadedGenera OutputImagePointerType outputPtr = this->GetOutput(); itk::ImageRegionIteratorWithIndex<OutputImageType> outputIt(outputPtr, outputRegionForThread); - - // Go to begin outputIt.GoToBegin(); // Set-up progress reporting @@ -154,13 +123,11 @@ void ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::ThreadedGenera inputIndex[dim] = outputIt.GetIndex()[dim] - m_Radius[dim]; inputSize[dim] = 2 * m_Radius[dim] + 1; } - // Build the input region - InputRegionType inputRegion; - inputRegion.SetIndex(inputIndex); - inputRegion.SetSize(inputSize); + + // Build the input region + InputRegionType inputRegion = {inputIndex, inputSize}; inputRegion.Crop(inputPtr->GetRequestedRegion()); - SizeType neighborhoodRadius; /** calculate minimum offset and set it as neighborhood radius **/ unsigned int minRadius = 0; @@ -178,8 +145,8 @@ void ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::ThreadedGenera GLCIList->Initialize(m_NumberOfBinsPerAxis, m_InputImageMinimum, m_InputImageMaximum); typedef itk::ConstNeighborhoodIterator<InputImageType> NeighborhoodIteratorType; - NeighborhoodIteratorType neighborIt; - neighborIt = NeighborhoodIteratorType(neighborhoodRadius, inputPtr, inputRegion); + NeighborhoodIteratorType neighborIt = NeighborhoodIteratorType(neighborhoodRadius, inputPtr, inputRegion); + for (neighborIt.GoToBegin(); !neighborIt.IsAtEnd(); ++neighborIt) { const InputPixelType centerPixelIntensity = neighborIt.GetCenterPixel(); @@ -201,8 +168,8 @@ void ScalarImageToPanTexTextureFilter<TInputImage, TOutputImage>::ThreadedGenera constVectorIt = glcVector.begin(); while (constVectorIt != glcVector.end()) { - CooccurrenceIndexType index = (*constVectorIt).first; - RelativeFrequencyType frequency = (*constVectorIt).second / totalFrequency; + CooccurrenceIndexType index = constVectorIt->first; + RelativeFrequencyType frequency = constVectorIt->second / totalFrequency; inertia += (index[0] - index[1]) * (index[0] - index[1]) * frequency; ++constVectorIt; }