Commit b5f961eb authored by Julien Michel's avatar Julien Michel

Merge branch 'haralick_in_software_guide' into 'develop'

Add Haralick features formulas in software guide

Closes #1711

See merge request !335
parents c909ecfc e844d308
......@@ -69,7 +69,6 @@ def GetApplicationExamplePythonSnippet(app,idx,expand = False, inputpath="",outp
output = ""
output += ".. code-block:: python\n\n"
# Render example comment
if len(app.GetExampleComment(idx)) > 0:
output += "\t# {}\n".format(app.GetExampleComment(idx))
......
......@@ -11,16 +11,25 @@ etc. They can also be measures : moments, textures, etc.
\subsection{Haralick Descriptors}
This example illustrates the use of the \doxygen{otb}{ScalarImageToTexturesFilter},
which compute the standard Haralick's textural features~\cite{Haralick1973} presented in table~\ref{tab:haralickStandardFeatures},
where $\mu_t$ and $\sigma_t$ are the mean and standard deviation of the row
(or column, due to symmetry) sums, $ \mu = $ (weighted pixel average)
$ = \sum_{i,j}i \cdot g(i, j) =\sum_{i,j}j \cdot g(i, j) $ due to matrix summetry, and
$ \sigma = $ (weighted pixel variance) $ = \sum_{i,j}(i - \mu)^2 \cdot g(i, j) =\sum_{i,j}(j - \mu)^2 \cdot g(i, j) $
due to matrix symmetry.
which computes the standard Haralick's textural features~\cite{Haralick1973}.
The \doxygen{otb}{ScalarImageToTexturesFilter} class computes 8 local Haralick
textures features presented in table~\ref{tab:haralickStandardFeatures},
where :
\begin{itemize}
\item $\mu_t$ and $\sigma_t$ are the mean and standard deviation of the row
(or column, due to symmetry) sums
\item $ \mu = $ (weighted pixel average)
$ = \sum_{i,j}i \cdot g(i, j) =\sum_{i,j}j \cdot g(i, j) $ due to matrix
symmetry
\item $ \sigma = $ (weighted pixel variance) $ = \sum_{i,j}(i - \mu)^2 \cdot g(i, j) =\sum_{i,j}(j - \mu)^2 \cdot g(i, j) $
due to matrix symmetry
\end{itemize}
\begin{table}
\begin{center}
\begin{tabular}{|c|c|}
\begin{tabular}[h!]{|c|c|}
\hline
& \\
Energy & $ f_1 = \sum_{i,j}g(i, j)^2 $ \\
......@@ -59,12 +68,139 @@ Haralick's Correlation & $ f_8 = \frac{\sum_{i,j}(i, j) g(i, j) -\mu_t^2}{\sigma
\label{tab:haralickStandardFeatures}
\end{table}
More features are available in \doxygen{otb}{ScalarImageToAdvancedTexturesFilter}.
Note that more features are available in
\doxygen{otb}{ScalarImageToAdvancedTexturesFilter} and in
\doxygen{otb}{ScalarImageToHigherOrderTexturesFilter}.
\doxygen{otb}{ScalarImageToAdvancedTexturesFilter} computes 10 advanced
texture features presented presented in table~\ref{tab:haralickAdvancedFeatures},
where:
\begin{itemize}
\item $ \mu = $ (weighted pixel average) = $ \sum_{i, j}i \cdot g(i, j) =
\sum_{i,j}j \cdot g(i, j) $ (due to matrix symmetry)
\item $N_{g}$ : Number of distinct gray levels in the quantized image
\item $ g_{x+y}(k) = \sum_{i}\sum_{j}g(i) $ where $ i+j=k $ and $ k = 2, 3, .., 2N_{g} $ and $ g_{x-y}(k) = \sum_{i}\sum_{j}g(i) $ where $ i-j=k $ and $ k = 0, 1, ..,N_{g}-1 $
\end{itemize}
\begin{table}
\begin{center}
\begin{tabular}[h!]{|c|c|}
\hline
& \\
Mean & $ f_{mean} = \sum_{i, j}i g(i, j) $ \\
& \\
\hline
& \\
Sum of squares: Variance & $ f_4 = \sum_{i, j}(i - \mu)^2 g(i, j) $ \\
& \\
\hline
& \\
Dissimilarity & $ f_5 = \sum_{i, j}(i - j) g(i, j)^2 $ \\
& \\
\hline
& \\
Sum average & $ f_6 = -\sum_{i}i g_{x+y}(i) $ \\
& \\
\hline
& \\
Sum Variance & $ f_7 = \sum_{i}(i - f_8)^2 g_{x+y}(i) $ \\
& \\
\hline
& \\
Sum Entropy & $ f_8 = -\sum_{i}g_{x+y}(i) log (g_{x+y}(i)) $ \\
& \\
\hline
Difference variance & $ f_{10} = variance of g_{x-y}(i) $ \\
& \\
\hline
& \\
Difference entropy & $ f_{11} = -\sum_{i}g_{x-y}(i) log (g_{x-y}(i)) $ \\
& \\
\hline
& \\
Information Measures of Correlation IC1 & $ f_{12} = \frac{f_9 - HXY1}{H} $ \\
& \\
\hline
& \\
Information Measures of Correlation IC2 & $ f_{13} = \sqrt{1 - \exp{-2}|HXY2 - f_9|} $ \\
& \\
\hline
\end{tabular}
\itkcaption[Haralick features]{Haralick features~\cite{Haralick1973} available in \doxygen{otb}{ScalarImageToAdvancedTexturesFilter}}
\end{center}
\label{tab:haralickAdvancedFeatures}
\end{table}
\doxygen{otb}{ScalarImageToHigherOrderTexturesFilter} computes 10
other local higher order statistics textures coefficients also based on the grey
level run-length matrix. Formulas for these coefficients are presented in
table~\ref{tab:haralickHigherOrderFeatures},where:
\begin{itemize}
\item $p(i, j)$ is the element in cell i
\item j of a normalized Run Length Matrix
\item $n_r$ is the total number of runs
\item $n_p$ is the total number of pixels
\end{itemize}
\begin{table}
\begin{center}
\begin{tabular}[h!]{|c|c|}
\hline
& \\
Short Run Emphasis & $ SRE = \frac{1}{n_r} \sum_{i, j}\frac{p(i, j)}{j^2} $ \\
& \\
\hline
& \\
Long Run Emphasis & $ LRE = \frac{1}{n_r} \sum_{i, j}p(i, j) * j^2 $ \\
& \\
\hline
& \\
Grey-Level Nonuniformity & $ GLN = \frac{1}{n_r} \sum_{i} \left( \sum_{j}{p(i, j)} \right)^2 $ \\
& \\
\hline
& \\
Run Length Nonuniformity & $ RLN = \frac{1}{n_r} \sum_{j} \left( \sum_{i}{p(i, j)} \right)^2 $ \\
& \\
\hline
& \\
Low Grey-Level Run Emphasis & $ LGRE = \frac{1}{n_r} \sum_{i, j}\frac{p(i, j)}{i^2} $ \\
& \\
\hline
& \\
High Grey-Level Run Emphasis & $ HGRE = \frac{1}{n_r} \sum_{i, j}p(i, j) * i^2 $ \\
& \\
\hline
Short Run Low Grey-Level Emphasis & $ SRLGE = \frac{1}{n_r} \sum_{i, j}\frac{p(i, j)}{i^2 j^2} $ \\
& \\
\hline
& \\
Short Run High Grey-Level Emphasis & $ SRHGE = \frac{1}{n_r} \sum_{i, j}\frac{p(i, j) * i^2}{j^2} $ \\
& \\
\hline
& \\
Long Run Low Grey-Level Emphasis & $ LRLGE = \frac{1}{n_r} \sum_{i, j}\frac{p(i, j) * j^2}{i^2} $ \\
& \\
\hline
& \\
Long Run High Grey-Level Emphasis & $ LRHGE = \frac{1}{n_r} \sum_{i, j} p(i, j) i^2 j^2 $ \\
& \\
\hline
\end{tabular}
\itkcaption[Haralick higher order features]{Haralick features~\cite{Haralick1973} available in \doxygen{otb}{ScalarImageToHigherOrderTexturesFilter}}
\end{center}
\label{tab:haralickHigherOrderFeatures}
\end{table}
\relatedClasses
\begin{itemize}
\item \doxygen{otb}{ScalarImageToAdvancedTexturesFilter}
\item \doxygen{otb}{ScalarImageToPanTexTextureFilter}
\item \doxygen{otb}{GreyLevelCooccurrenceIndexedList}
\item \doxygen{otb}{ScalarImageToHigherOrderTexturesFilter}
\end{itemize}
\input{TextureExample}
......
......@@ -81,16 +81,21 @@ SetDocLongDescription(
"Entropy (measure of randomness of intensity image), Correlation (how "
"correlated a pixel is to its neighborhood), Inverse Difference Moment (measures "
"the texture homogeneity), Inertia (intensity contrast between a pixel and its "
"neighborhood), Cluster Shade, Cluster Prominence, Haralick Correlation;\n"
"neighborhood), Cluster Shade, Cluster Prominence, Haralick Correlation;\n\n"
"* advanced: a set of 10 advanced Haralick features: Mean, Variance (measures the "
"texture heterogeneity), Dissimilarity, Sum Average, Sum Variance, Sum Entropy, "
"Difference of Entropies, Difference of Variances, IC1, IC2;\n"
"Difference of Entropies, Difference of Variances, IC1, IC2;\n\n"
"* higher: a set of 11 higher Haralick features: Short Run Emphasis (measures the "
"texture sharpness), Long Run Emphasis (measures the texture roughness), Grey-Level "
"Nonuniformity, Run Length Nonuniformity, Run Percentage (measures the texture "
"sharpness homogeneity), Low Grey-Level Run Emphasis, High Grey-Level Run Emphasis, "
"Short Run Low Grey-Level Emphasis, Short Run High Grey-Level Emphasis, Long Run Low "
"Grey-Level Emphasis and Long Run High Grey-Level Emphasis.");
"Grey-Level Emphasis and Long Run High Grey-Level Emphasis.\n\n"
"The documentation of textures (description are formulas) are available in the OTB Software Guide (section Textures) and also in corresponding doxygen "
"documentation of filters (see section *Detailed Description* in doxygen):\n"
"* **simple**: otbScalarImageToTexturesFilter\n"
"* **advanced**: otbScalarImageToAdvancedTexturesFilter\n"
"* **higher**: otbScalarImageToHigherOrderTexturesFilter");
SetDocLimitations("The computation of the features is based on a Gray Level Co-occurrence "
"matrix (GLCM) from the quantized input image. Consequently the quantization "
......@@ -313,7 +318,6 @@ void DoExecute() override
m_HigImageList->PushBack(m_HigTexFilter->GetLongRunEmphasisOutput());
m_HigImageList->PushBack(m_HigTexFilter->GetGreyLevelNonuniformityOutput());
m_HigImageList->PushBack(m_HigTexFilter->GetRunLengthNonuniformityOutput());
m_HigImageList->PushBack(m_HigTexFilter->GetRunPercentageOutput());
m_HigImageList->PushBack(m_HigTexFilter->GetLowGreyLevelRunEmphasisOutput());
m_HigImageList->PushBack(m_HigTexFilter->GetHighGreyLevelRunEmphasisOutput());
m_HigImageList->PushBack(m_HigTexFilter->GetShortRunLowGreyLevelEmphasisOutput());
......
......@@ -24,6 +24,7 @@
#include "otbGreyLevelCooccurrenceIndexedList.h"
#include "itkMacro.h"
#include "itkImageToImageFilter.h"
namespace otb
{
/**
......@@ -43,7 +44,7 @@ namespace otb
* window. :(where each element in GLCIL is a pair of pixel index and it's
* frequency, $ g(i, j) $ is the frequency value of the pair having index is i, j).
*
* "Mean" \f$ = \sum_{i, j}i g(i, j) \f$
* "Mean" \f$ = f_{mean} = \sum_{i, j}i g(i, j) \f$
*
* "Sum of squares: Variance" \f$ = f_4 = \sum_{i, j}(i - \mu)^2 g(i, j) \f$
*
......@@ -55,22 +56,23 @@ namespace otb
*
* "Sum Entropy" \f$= f_8 = -\sum_{i}g_{x+y}(i) log (g_{x+y}(i)) \f$
*
* "Difference variance" \f$ = f_10 = variance of g_{x-y}(i) \f$
* "Difference variance" \f$ = f_{10} = variance of g_{x-y}(i) \f$
*
* "Difference entropy" \f$ = f_11 = -\sum_{i}g_{x-y}(i) log (g_{x-y}(i)) \f$
* "Difference entropy" \f$ = f_{11} = -\sum_{i}g_{x-y}(i) log (g_{x-y}(i)) \f$
*
* "Information Measures of Correlation IC1" \f$ = f_12 = \frac{f_9 - HXY1}{H} \f$
* "Information Measures of Correlation IC1" \f$ = f_{12} = \frac{f_9 - HXY1}{H} \f$
*
* "Information Measures of Correlation IC2" \f$ = f_13 = \sqrt{1 - \exp{-2}|HXY2 - f_9|} \f$
* "Information Measures of Correlation IC2" \f$ = f_{13} = \sqrt{1 - \exp{-2}|HXY2 - f_9|} \f$
*
* Above, \f$ \mu = \f$ (weighted pixel average) \f$ = \sum_{i, j}i \cdot g(i, j) =
* \sum_{i, j}j \cdot g(i, j) \f$ (due to matrix summetry), and
* \sum_{i, j}j \cdot g(i, j) \f$ (due to matrix simmetry), and
*
* \f$ \g_{x+y}(k) = \sum_{i}\sum_{j}g(i)\f$ where \f$ i+j=k \f$ and \f$ k = 2, 3, .., 2N_[g} \f$ and
* \f$ g_{x+y}(k) = \sum_{i}\sum_{j}g(i)\f$ where \f$ i+j=k \f$ and \f$ k = 2, 3, .., 2N_{g} \f$ and
*
* \f$ \g_{x-y}(k) = \sum_{i}\sum_{j}g(i)\f$ where \f$ i-j=k \f$ and \f$ k = 0, 1, .., N_[g}-1 \f$
* \f$ g_{x-y}(k) = \sum_{i}\sum_{j}g(i)\f$ where \f$ i-j=k \f$ and \f$ k = 0, 1, .., N_{g}-1 \f$
* \f$N_{g}\f$ : Number of distinct gray levels in the quantized image.
*
* Print references:
* References:
*
* Haralick, R.M., K. Shanmugam and I. Dinstein. 1973. Textural Features for
* Image Classification. IEEE Transactions on Systems, Man and Cybernetics.
......
......@@ -27,7 +27,7 @@
namespace otb
{
/** \class ScalarImageToHigherOrderTexturesFilter
* \brief This class compute 11 local higher order statistics textures coefficients
* \brief This class compute 10 local higher order statistics textures coefficients
* based on the grey level run-length matrix
*
* This filter computes the following Haralick textures over a sliding window with
......@@ -96,20 +96,8 @@ public:
typedef typename OutputImageType::Pointer OutputImagePointerType;
typedef typename OutputImageType::RegionType OutputRegionType;
/** Co-occurence matrix and textures calculator */
/* typedef otb::MaskedScalarImageToGreyLevelRunLengthMatrixGenerator
<InputImageType> RunLengthMatrixGeneratorType;
typedef typename RunLengthMatrixGeneratorType::Pointer RunLengthMatrixGeneratorPointerType;
typedef typename RunLengthMatrixGeneratorType::OffsetType OffsetType;
typedef typename RunLengthMatrixGeneratorType::HistogramType HistogramType;
typedef itk::Statistics::GreyLevelRunLengthMatrixTextureCoefficientsCalculator
<HistogramType> TextureCoefficientsCalculatorType;
typedef typename TextureCoefficientsCalculatorType::Pointer TextureCoefficientsCalculatorPointerType;
*/
typedef itk::Statistics::ScalarImageToRunLengthFeaturesFilter
<InputImageType> ScalarImageToRunLengthFeaturesFilterType;
//typedef typename ImageType::PixelType PixelType;
typedef typename InputImageType::OffsetType OffsetType;
typedef itk::VectorContainer< unsigned char, OffsetType > OffsetVector;
typedef typename OffsetVector::Pointer OffsetVectorPointer;
......@@ -175,9 +163,6 @@ public:
/** Get the Run Length Nonuniformity output image */
OutputImageType * GetRunLengthNonuniformityOutput();
/** Get the Run Percentage output image */
OutputImageType * GetRunPercentageOutput();
/** Get the Low Grey-Level Run Emphasis output image */
OutputImageType * GetLowGreyLevelRunEmphasisOutput();
......
......@@ -39,7 +39,7 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
m_SubsampleFactor(),
m_SubsampleOffset()
{
// There are 11 outputs corresponding to the 8 textures indices
// There are 10 outputs corresponding to the 8 textures indices
this->SetNumberOfRequiredOutputs(10);
// Create the 11 outputs
......@@ -53,7 +53,6 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
this->SetNthOutput(7, OutputImageType::New());
this->SetNthOutput(8, OutputImageType::New());
this->SetNthOutput(9, OutputImageType::New());
this->SetNthOutput(10, OutputImageType::New());
m_Radius.Fill(10);
......@@ -91,11 +90,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetShortRunEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 1)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(0));
return this->GetOutput(0);
}
template <class TInputImage, class TOutputImage>
......@@ -104,11 +99,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLongRunEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 2)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(1));
return this->GetOutput(1);
}
template <class TInputImage, class TOutputImage>
......@@ -117,11 +108,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetGreyLevelNonuniformityOutput()
{
if (this->GetNumberOfOutputs() < 3)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(2));
return this->GetOutput(2);
}
template <class TInputImage, class TOutputImage>
......@@ -130,24 +117,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetRunLengthNonuniformityOutput()
{
if (this->GetNumberOfOutputs() < 4)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(3));
}
template <class TInputImage, class TOutputImage>
typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::OutputImageType *
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetRunPercentageOutput()
{
if (this->GetNumberOfOutputs() < 5)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(4));
return this->GetOutput(3);
}
template <class TInputImage, class TOutputImage>
......@@ -156,11 +126,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLowGreyLevelRunEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 6)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(5));
return this->GetOutput(4);
}
template <class TInputImage, class TOutputImage>
......@@ -169,11 +135,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetHighGreyLevelRunEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 7)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(6));
return this->GetOutput(5);
}
template <class TInputImage, class TOutputImage>
......@@ -182,11 +144,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetShortRunLowGreyLevelEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 8)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(7));
return this->GetOutput(6);
}
template <class TInputImage, class TOutputImage>
......@@ -195,11 +153,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetShortRunHighGreyLevelEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 9)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(8));
return this->GetOutput(7);
}
template <class TInputImage, class TOutputImage>
......@@ -208,11 +162,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLongRunLowGreyLevelEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 10)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(9));
return this->GetOutput(8);
}
template <class TInputImage, class TOutputImage>
......@@ -221,11 +171,7 @@ typename ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GetLongRunHighGreyLevelEmphasisOutput()
{
if (this->GetNumberOfOutputs() < 11)
{
return nullptr;
}
return static_cast<OutputImageType *>(this->GetOutput(10));
return this->GetOutput(9);
}
template <class TInputImage, class TOutputImage>
......@@ -243,33 +189,33 @@ void
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::GenerateOutputInformation()
{
// First, call superclass implementation
Superclass::GenerateOutputInformation();
// Compute output size, origin & spacing
InputRegionType inputRegion = this->GetInput()->GetLargestPossibleRegion();
const InputImageType * inputPtr = this->GetInput();
InputRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
OutputRegionType outputRegion;
outputRegion.SetIndex(0,0);
outputRegion.SetIndex(1,0);
outputRegion.SetSize(0, 1 + (inputRegion.GetSize(0) - 1 - m_SubsampleOffset[0]) / m_SubsampleFactor[0]);
outputRegion.SetSize(1, 1 + (inputRegion.GetSize(1) - 1 - m_SubsampleOffset[1]) / m_SubsampleFactor[1]);
typename OutputImageType::SpacingType outSpacing = this->GetInput()->GetSignedSpacing();
typename OutputImageType::SpacingType outSpacing = inputPtr->GetSignedSpacing();
outSpacing[0] *= m_SubsampleFactor[0];
outSpacing[1] *= m_SubsampleFactor[1];
typename OutputImageType::PointType outOrigin;
this->GetInput()->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin);
inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex()+m_SubsampleOffset,outOrigin);
for (unsigned int i=0 ; i<this->GetNumberOfOutputs() ; i++)
for (unsigned int i=0 ; i < this->GetNumberOfOutputs() ; i++)
{
OutputImagePointerType outputPtr = this->GetOutput(i);
outputPtr->CopyInformation(inputPtr);
outputPtr->SetLargestPossibleRegion(outputRegion);
outputPtr->SetOrigin(outOrigin);
outputPtr->SetSignedSpacing(outSpacing);
}
}
template <class TInputImage, class TOutputImage>
void
ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
......@@ -300,7 +246,7 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
outputIndex[1] = outputIndex[1] * m_SubsampleFactor[1] + m_SubsampleOffset[1] + inputLargest.GetIndex(1);
outputSize[0] = 1 + (outputSize[0] - 1) * m_SubsampleFactor[0];
outputSize[1] = 1 + (outputSize[1] - 1) * m_SubsampleFactor[1];
InputRegionType inputRequestedRegion(outputIndex,outputSize);
// Apply the radius
......@@ -328,12 +274,12 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
::ThreadedGenerateData(const OutputRegionType& outputRegionForThread, itk::ThreadIdType threadId)
{
// Retrieve the input and output pointers
InputImagePointerType inputPtr = const_cast<InputImageType *>(this->GetInput());
const InputImageType * inputPtr = this->GetInput();
typedef typename itk::ImageRegionIterator<OutputImageType> IteratorType;
std::vector<IteratorType> outputImagesIterators;
for (unsigned int i = 0; i < 10; ++i)
for (unsigned int i = 0; i < this->GetNumberOfOutputs(); ++i)
{
outputImagesIterators.push_back( IteratorType(this->GetOutput(i), outputRegionForThread) );
outputImagesIterators[i].GoToBegin();
......@@ -381,7 +327,8 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
localInputImage->SetRegions(inputRegion);
localInputImage->Allocate();
typedef itk::ImageRegionIteratorWithIndex<InputImageType> ImageRegionIteratorType;
ImageRegionIteratorType itInputPtr(inputPtr, inputRegion);
typedef itk::ImageRegionConstIteratorWithIndex<InputImageType> ImageRegionConstIteratorType;
ImageRegionConstIteratorType itInputPtr(inputPtr, inputRegion);
ImageRegionIteratorType itLocalInputImage(localInputImage, inputRegion);
for (itInputPtr.GoToBegin(), itLocalInputImage.GoToBegin();
!itInputPtr.IsAtEnd();
......@@ -402,28 +349,17 @@ ScalarImageToHigherOrderTexturesFilter<TInputImage, TOutputImage>
typename ScalarImageToRunLengthFeaturesFilterType::FeatureValueVector&
featuresMeans = *(runLengthFeatureCalculator->GetFeatureMeans().GetPointer());
// Fill outputs
outputImagesIterators[0].Set(featuresMeans[0]);
outputImagesIterators[1].Set(featuresMeans[1]);
outputImagesIterators[2].Set(featuresMeans[2]);
outputImagesIterators[3].Set(featuresMeans[3]);
outputImagesIterators[4].Set(featuresMeans[4]);
outputImagesIterators[5].Set(featuresMeans[5]);
outputImagesIterators[6].Set(featuresMeans[6]);
outputImagesIterators[7].Set(featuresMeans[7]);
outputImagesIterators[8].Set(featuresMeans[8]);
outputImagesIterators[9].Set(featuresMeans[9]);
// Fill output
for (unsigned int i = 0; i < this->GetNumberOfOutputs(); ++i)
{
// Fill output
outputImagesIterators[i].Set(featuresMeans[i]);
// Increment iterators
++outputImagesIterators[i];
}
// Update progress
progress.CompletedPixel();
// Increment iterators
for (unsigned int i = 0; i < 10; ++i)
{
++outputImagesIterators[i];
}
}
}
} // End namespace otb
......
......@@ -64,13 +64,13 @@ namespace otb
* (or column, due to symmetry) sums.
*
* Above, \f$ \mu = \f$ (weighted pixel average) \f$ = \sum_{i, j}i \cdot g(i, j) =
* \sum_{i, j}j \cdot g(i, j) \f$ (due to matrix summetry), and
* \sum_{i, j}j \cdot g(i, j) \f$ (due to matrix symmetry), and
*
* \f$ \sigma = \f$ (weighted pixel variance) \f$ = \sum_{i, j}(i - \mu)^2 \cdot g(i, j) =
* \sum_{i, j}(j - \mu)^2 \cdot g(i, j) \f$ (due to matrix summetry)
* \sum_{i, j}(j - \mu)^2 \cdot g(i, j) \f$ (due to matrix symmetry)
*
* Print references:
* References:
*
* Haralick, R.M., K. Shanmugam and I. Dinstein. 1973. Textural Features for
* Image Classification. IEEE Transactions on Systems, Man and Cybernetics.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment