Skip to content
Snippets Groups Projects
Commit 619a1ae3 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

ENH: Using GreyLevelCooccurrenceIndexedList in simple and advanced haralick textures

parent 71b42690
No related branches found
No related tags found
No related merge requests found
...@@ -107,6 +107,9 @@ public: ...@@ -107,6 +107,9 @@ public:
/** Get std::vector containing non-zero co-occurrence pairs */ /** Get std::vector containing non-zero co-occurrence pairs */
VectorType GetVector(); VectorType GetVector();
/** Normailze the GLCIL */
void Normalize();
/** Add the CooccurrencePairType to list. Next occurrence of same index is /** Add the CooccurrencePairType to list. Next occurrence of same index is
* checked via m_LookupArray value and the correspoding frequency value is * checked via m_LookupArray value and the correspoding frequency value is
* incremented. If m_Symmetry is true the co-occurrence pair is added again */ * incremented. If m_Symmetry is true the co-occurrence pair is added again */
......
...@@ -43,6 +43,20 @@ GreyLevelCooccurrenceIndexedList<THistogram> ...@@ -43,6 +43,20 @@ GreyLevelCooccurrenceIndexedList<THistogram>
m_TotalFrequency = 0; m_TotalFrequency = 0;
} }
template <class THistogram >
void
GreyLevelCooccurrenceIndexedList<THistogram>
::Normalize()
{
//Normalize the co-occurrence indexed list
typename VectorType::iterator it = m_Vector.begin();
while( it != m_Vector.end())
{
(*it).frequency = (*it).frequency / m_TotalFrequency;
++it;
}
}
template <class THistogram > template <class THistogram >
typename GreyLevelCooccurrenceIndexedList<THistogram>::RelativeFrequencyType typename GreyLevelCooccurrenceIndexedList<THistogram>::RelativeFrequencyType
GreyLevelCooccurrenceIndexedList<THistogram>:: GreyLevelCooccurrenceIndexedList<THistogram>::
......
...@@ -18,10 +18,9 @@ ...@@ -18,10 +18,9 @@
#ifndef __otbScalarImageToAdvancedTexturesFilter_h #ifndef __otbScalarImageToAdvancedTexturesFilter_h
#define __otbScalarImageToAdvancedTexturesFilter_h #define __otbScalarImageToAdvancedTexturesFilter_h
#include "otbGreyLevelCooccurrenceIndexedList.h"
#include "itkImageToImageFilter.h" #include "itkImageToImageFilter.h"
#include "itkHistogram.h" #include "itkHistogram.h"
#include "itkArray.h"
#include <vector>
namespace otb namespace otb
{ {
...@@ -119,29 +118,16 @@ public: ...@@ -119,29 +118,16 @@ public:
typedef typename HistogramType::MeasurementVectorType MeasurementVectorType; typedef typename HistogramType::MeasurementVectorType MeasurementVectorType;
typedef typename HistogramType::RelativeFrequencyType RelativeFrequencyType; typedef typename HistogramType::RelativeFrequencyType RelativeFrequencyType;
typedef typename HistogramType::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType; typedef typename HistogramType::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType;
typedef typename HistogramType::IndexType HistogramIndexType; typedef typename HistogramType::SizeType HistogramSizeType;
typedef typename HistogramType::IndexType CooccurrenceIndexType;
/** Lookup array used to store the index of the given pixel pair. This index typedef GreyLevelCooccurrenceIndexedList< HistogramType > CooccurrenceIndexedListType;
* is calculated from the HistogramType */ typedef typename CooccurrenceIndexedListType::Pointer CooccurrenceIndexedListPointerType;
typedef itk::Array<int> LookupArrayType; typedef typename CooccurrenceIndexedListType::ConstPointer CooccurrenceIndexedListConstPointerType;
/** struct to hold the index of pixel pair and its frequency. The frequnecy is typedef typename CooccurrenceIndexedListType::VectorType VectorType;
* incremented for the next occurrence of the same pair */ typedef typename VectorType::iterator VectorIteratorType;
typedef typename VectorType::const_iterator VectorConstIteratorType;
typedef struct Cooccurrence {
HistogramIndexType index;
RelativeFrequencyType frequency;
}CooccurrenceType;
/** array to hold CooccurrenceType. Index of the array where the cooccurrence
* is stored is saved in the LookupArrayType. */
typedef std::vector<CooccurrenceType> GreyLevelCooccurrenceListType;
/** std::vector iterator typedef for GreyLevelCooccurrenceListType */
typedef typename std::vector<CooccurrenceType>::iterator GreyLevelCooccurrenceListIteratorType;
/** std::vector const_iterator typedef for GreyLevelCooccurrenceListType */
typedef typename std::vector<CooccurrenceType>::const_iterator GreyLevelCooccurrenceListConstIteratorType;
itkStaticConstMacro(MeasurementVectorSize, int, 2 ); itkStaticConstMacro(MeasurementVectorSize, int, 2 );
...@@ -174,6 +160,8 @@ public: ...@@ -174,6 +160,8 @@ public:
/** Get the input image maximum */ /** Get the input image maximum */
itkGetMacro(InputImageMaximum, InputPixelType); itkGetMacro(InputImageMaximum, InputPixelType);
void SetBinsAndMinMax(unsigned int bins, InputPixelType min, InputPixelType max);
/** Get the mean output image */ /** Get the mean output image */
OutputImageType * GetMeanOutput(); OutputImageType * GetMeanOutput();
...@@ -209,13 +197,8 @@ protected: ...@@ -209,13 +197,8 @@ protected:
ScalarImageToAdvancedTexturesFilter(); ScalarImageToAdvancedTexturesFilter();
/** Destructor */ /** Destructor */
~ScalarImageToAdvancedTexturesFilter(); ~ScalarImageToAdvancedTexturesFilter();
/** Before ThreadedGenerateData created a single histogram instance **/
virtual void BeforeThreadedGenerateData( );
/** Generate the input requested region */ /** Generate the input requested region */
virtual void GenerateInputRequestedRegion(); virtual void GenerateInputRequestedRegion();
/** Parallel textures extraction */ /** Parallel textures extraction */
virtual void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId); virtual void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId);
...@@ -247,6 +230,8 @@ private: ...@@ -247,6 +230,8 @@ private:
/** Histogram instance used to get index for the pixel pair */ /** Histogram instance used to get index for the pixel pair */
HistogramPointer m_Histogram; HistogramPointer m_Histogram;
HistogramSizeType m_HistSize;
}; };
} // End namespace otb } // End namespace otb
......
...@@ -19,6 +19,7 @@ PURPOSE. See the above copyright notices for more information. ...@@ -19,6 +19,7 @@ PURPOSE. See the above copyright notices for more information.
#ifndef __otbScalarImageToTexturesFilter_h #ifndef __otbScalarImageToTexturesFilter_h
#define __otbScalarImageToTexturesFilter_h #define __otbScalarImageToTexturesFilter_h
#include "otbGreyLevelCooccurrenceIndexedList.h"
#include "itkImageToImageFilter.h" #include "itkImageToImageFilter.h"
#include "itkHistogram.h" #include "itkHistogram.h"
...@@ -130,30 +131,18 @@ public: ...@@ -130,30 +131,18 @@ public:
typedef typename HistogramType::MeasurementVectorType MeasurementVectorType; typedef typename HistogramType::MeasurementVectorType MeasurementVectorType;
typedef typename HistogramType::RelativeFrequencyType RelativeFrequencyType; typedef typename HistogramType::RelativeFrequencyType RelativeFrequencyType;
typedef typename HistogramType::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType; typedef typename HistogramType::TotalAbsoluteFrequencyType TotalAbsoluteFrequencyType;
typedef typename HistogramType::IndexType HistogramIndexType; typedef typename HistogramType::SizeType HistogramSizeType;
typedef typename HistogramType::IndexType CooccurrenceIndexType;
typedef GreyLevelCooccurrenceIndexedList< HistogramType > CooccurrenceIndexedListType;
typedef typename CooccurrenceIndexedListType::Pointer CooccurrenceIndexedListPointerType;
typedef typename CooccurrenceIndexedListType::ConstPointer CooccurrenceIndexedListConstPointerType;
/** Lookup array used to store the index of the given pixel pair. This index typedef typename CooccurrenceIndexedListType::VectorType VectorType;
* is calculated from the HistogramType */ typedef typename VectorType::iterator VectorIteratorType;
typedef itk::Array<int> LookupArrayType; typedef typename VectorType::const_iterator VectorConstIteratorType;
/** struct to hold the index of pixel pair and its frequency. The frequnecy is void SetBinsAndMinMax(unsigned int bins, InputPixelType min, InputPixelType max);
* incremented for the next occurrence of the same pair */
typedef struct Cooccurrence {
HistogramIndexType index;
RelativeFrequencyType frequency;
}CooccurrenceType;
/** array to hold CooccurrenceType. Index of the array where the cooccurrence
* is stored is saved in the LookupArrayType. */
typedef std::vector<CooccurrenceType> GreyLevelCooccurrenceListType;
/** std::vector iterator typedef for GreyLevelCooccurrenceListType */
typedef typename std::vector<CooccurrenceType>::iterator GreyLevelCooccurrenceListIteratorType;
/** std::vector const_iterator typedef for GreyLevelCooccurrenceListType */
typedef typename std::vector<CooccurrenceType>::const_iterator GreyLevelCooccurrenceListConstIteratorType;
itkStaticConstMacro(MeasurementVectorSize, int, 2 ); itkStaticConstMacro(MeasurementVectorSize, int, 2 );
...@@ -217,10 +206,6 @@ protected: ...@@ -217,10 +206,6 @@ protected:
~ScalarImageToTexturesFilter(); ~ScalarImageToTexturesFilter();
/** Generate the input requested region */ /** Generate the input requested region */
virtual void GenerateInputRequestedRegion(); virtual void GenerateInputRequestedRegion();
/** Before ThreadedGenerateData created a single histogram instance **/
virtual void BeforeThreadedGenerateData( );
/** Parallel textures extraction */ /** Parallel textures extraction */
virtual void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId); virtual void ThreadedGenerateData(const OutputRegionType& outputRegion, itk::ThreadIdType threadId);
...@@ -252,9 +237,11 @@ private: ...@@ -252,9 +237,11 @@ private:
/** Histogram instance used to get index for the pixel pair */ /** Histogram instance used to get index for the pixel pair */
HistogramPointer m_Histogram; HistogramPointer m_Histogram;
HistogramSizeType m_HistSize;
/** This method is same as ComputeMeansAndVariance in /** This method is same as ComputeMeansAndVariance in
* itkHistogramToTexturesFilter. This has been modified for using new GLCIL */ * itkHistogramToTexturesFilter. This has been modified for using new GLCIL */
void ComputeMeansAndVariances(GreyLevelCooccurrenceListType& frequencyList, double & pixelMean, void ComputeMeansAndVariances(VectorType& frequencyList, double & pixelMean,
double & marginalMean, double & marginalDevSquared, double & pixelVariance); double & marginalMean, double & marginalDevSquared, double & pixelVariance);
}; };
......
...@@ -31,11 +31,13 @@ namespace otb ...@@ -31,11 +31,13 @@ namespace otb
{ {
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
ScalarImageToTexturesFilter<TInputImage, TOutputImage> ScalarImageToTexturesFilter<TInputImage, TOutputImage>
::ScalarImageToTexturesFilter() : m_Radius(), ::ScalarImageToTexturesFilter()
m_Offset(), : m_Radius()
m_NumberOfBinsPerAxis(8), , m_Offset()
m_InputImageMinimum(0), , m_HistSize(2)
m_InputImageMaximum(255) , m_NumberOfBinsPerAxis(8)
, m_InputImageMinimum(0)
, m_InputImageMaximum(255)
{ {
// There are 8 outputs corresponding to the 8 textures indices // There are 8 outputs corresponding to the 8 textures indices
this->SetNumberOfRequiredOutputs(8); this->SetNumberOfRequiredOutputs(8);
...@@ -160,6 +162,43 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -160,6 +162,43 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
return static_cast<OutputImageType *>(this->GetOutput(7)); return static_cast<OutputImageType *>(this->GetOutput(7));
} }
template <class TInputImage, class TOutputImage>
void
ScalarImageToTexturesFilter<TInputImage, TOutputImage>
::SetBinsAndMinMax(unsigned int numberOfBinsPerAxis,
InputPixelType inputImageMinimum,
InputPixelType inputImageMaximum)
{
/** calulate minimum offset and set it as neigborhood radius **/
unsigned int minRadius = 0;
for ( unsigned int i = 0; i < m_Offset.GetOffsetDimension(); i++ )
{
unsigned int distance = vcl_abs(m_Offset[i]);
if ( distance > minRadius )
{
minRadius = distance;
}
}
m_NeighborhoodRadius.Fill(minRadius);
/** Initalize m_Histogram with given min, max and number of bins **/
MeasurementVectorType lowerBound;
MeasurementVectorType upperBound;
m_InputImageMinimum = inputImageMinimum;
m_InputImageMaximum = inputImageMaximum;
m_NumberOfBinsPerAxis = numberOfBinsPerAxis;
m_Histogram = HistogramType::New();
m_Histogram->SetMeasurementVectorSize( MeasurementVectorSize );
lowerBound.SetSize( MeasurementVectorSize );
upperBound.SetSize( MeasurementVectorSize );
lowerBound.Fill(m_InputImageMinimum);
upperBound.Fill(m_InputImageMaximum+1);
m_HistSize.Fill(m_NumberOfBinsPerAxis);
m_Histogram->Initialize(m_HistSize, lowerBound, upperBound);
}
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
void void
ScalarImageToTexturesFilter<TInputImage, TOutputImage> ScalarImageToTexturesFilter<TInputImage, TOutputImage>
...@@ -220,38 +259,6 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -220,38 +259,6 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
} }
} }
template <class TInputImage, class TOutputImage>
void
ScalarImageToTexturesFilter<TInputImage, TOutputImage>
::BeforeThreadedGenerateData()
{
/** Initalize m_Histogram with given min, max and number of bins **/
MeasurementVectorType m_LowerBound;
MeasurementVectorType m_UpperBound;
m_Histogram = HistogramType::New();
m_Histogram->SetMeasurementVectorSize( MeasurementVectorSize );
m_LowerBound.SetSize( MeasurementVectorSize );
m_UpperBound.SetSize( MeasurementVectorSize );
m_LowerBound.Fill(m_InputImageMinimum);
m_UpperBound.Fill(m_InputImageMaximum+1);
typename HistogramType::SizeType size( MeasurementVectorSize );
size.Fill(m_NumberOfBinsPerAxis);
m_Histogram->Initialize(size, m_LowerBound, m_UpperBound);
/** calulate minimum offset and set it as neigborhood radius **/
unsigned int minRadius = 0;
for ( unsigned int i = 0; i < m_Offset.GetOffsetDimension(); i++ )
{
unsigned int distance = vcl_abs(m_Offset[i]);
if ( distance > minRadius )
{
minRadius = distance;
}
}
m_NeighborhoodRadius.Fill(minRadius);
}
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
void void
ScalarImageToTexturesFilter<TInputImage, TOutputImage> ScalarImageToTexturesFilter<TInputImage, TOutputImage>
...@@ -321,20 +328,12 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -321,20 +328,12 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
inputRegion.SetSize(inputSize); inputRegion.SetSize(inputSize);
inputRegion.Crop(inputPtr->GetRequestedRegion()); inputRegion.Crop(inputPtr->GetRequestedRegion());
CooccurrenceIndexedListPointerType m_GLCIList = CooccurrenceIndexedListType::New();
m_GLCIList->Initialize(m_HistSize);
typedef itk::ConstNeighborhoodIterator< InputImageType > NeighborhoodIteratorType; typedef itk::ConstNeighborhoodIterator< InputImageType > NeighborhoodIteratorType;
NeighborhoodIteratorType neighborIt; NeighborhoodIteratorType neighborIt;
//initalize lookup array.
//unsigned int historamSize = m_Histogram->GetSize(0);
LookupArrayType lookupArray(m_NumberOfBinsPerAxis * m_NumberOfBinsPerAxis);
lookupArray.Fill(-1);
GreyLevelCooccurrenceListType glcList;
TotalAbsoluteFrequencyType totalFrequency = 0;
neighborIt = NeighborhoodIteratorType(m_NeighborhoodRadius, inputPtr, inputRegion); neighborIt = NeighborhoodIteratorType(m_NeighborhoodRadius, inputPtr, inputRegion);
for ( neighborIt.GoToBegin(); !neighborIt.IsAtEnd(); ++neighborIt ) for ( neighborIt.GoToBegin(); !neighborIt.IsAtEnd(); ++neighborIt )
{ {
...@@ -363,68 +362,19 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -363,68 +362,19 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
// is out-of-bounds. // is out-of-bounds.
} }
unsigned int instanceId = 0; CooccurrenceIndexType instanceIndex;
HistogramIndexType instanceIndex;
MeasurementVectorType measurement( MeasurementVectorSize ); MeasurementVectorType measurement( MeasurementVectorSize );
measurement[0] = centerPixelIntensity; measurement[0] = centerPixelIntensity;
measurement[1] = pixelIntensity; measurement[1] = pixelIntensity;
//Get Index of the histogram for the given pixel pair; //Get Index of the histogram for the given pixel pair;
m_Histogram->GetIndex(measurement, instanceIndex); m_Histogram->GetIndex(measurement, instanceIndex);
m_GLCIList->AddPairToList(instanceIndex);
//Find the 1D index of the historam index. This index is used to check the
//entry in lookup array.
instanceId = instanceIndex[1] * m_NumberOfBinsPerAxis + instanceIndex[0];
if( lookupArray[instanceId] < 0)
{
lookupArray[instanceId] = glcList.size();
CooccurrenceType cooccur;
cooccur.index = instanceIndex;
cooccur.frequency = 1;
glcList.push_back(cooccur);
}
else
{
int vindex = lookupArray[instanceId];
glcList[vindex].frequency++;
}
//For symmetry store the same pixel pair.
measurement[1] = centerPixelIntensity;
measurement[0] = pixelIntensity;
m_Histogram->GetIndex(measurement, instanceIndex);
instanceId = instanceIndex[1] * m_NumberOfBinsPerAxis + instanceIndex[0];
if( lookupArray[instanceId] < 0)
{
lookupArray[instanceId] = glcList.size();
CooccurrenceType cooccur;
cooccur.index = instanceIndex;
cooccur.frequency = 1;
glcList.push_back(cooccur);
}
else
{
int vindex = lookupArray[instanceId];
glcList[vindex].frequency = glcList[vindex].frequency + 1;
}
// Increment total frequency by two as we consider symmetry of
// cooccurrence pairs
totalFrequency = totalFrequency + 2;
} }
GreyLevelCooccurrenceListIteratorType vectorIt;
GreyLevelCooccurrenceListConstIteratorType covectorIt;
//Normalize the GreyLevelCooccurrenceListType m_GLCIList->Normalize();
vectorIt = glcList.begin(); VectorConstIteratorType constVectorIt;
while( vectorIt != glcList.end()) VectorType glcList = m_GLCIList->GetVector();
{
(*vectorIt).frequency = (*vectorIt).frequency / totalFrequency;
++vectorIt;
}
double pixelMean; double pixelMean;
double marginalMean; double marginalMean;
...@@ -456,11 +406,11 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -456,11 +406,11 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
} }
//Compute textures //Compute textures
covectorIt = glcList.begin(); constVectorIt = glcList.begin();
while( covectorIt != glcList.end()) while( constVectorIt != glcList.end())
{ {
HistogramIndexType index = (*covectorIt).index; CooccurrenceIndexType index = (*constVectorIt).index;
RelativeFrequencyType frequency = (*covectorIt).frequency; RelativeFrequencyType frequency = (*constVectorIt).frequency;
energy += frequency * frequency; energy += frequency * frequency;
entropy -= ( frequency > 0.0001 ) ? frequency *vcl_log(frequency) / log2:0; entropy -= ( frequency > 0.0001 ) ? frequency *vcl_log(frequency) / log2:0;
correlation += ( ( index[0] - pixelMean ) * ( index[1] - pixelMean ) * frequency ) / pixelVarianceSquared; correlation += ( ( index[0] - pixelMean ) * ( index[1] - pixelMean ) * frequency ) / pixelVarianceSquared;
...@@ -469,7 +419,7 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -469,7 +419,7 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
clusterShade += vcl_pow( ( index[0] - pixelMean ) + ( index[1] - pixelMean ), 3 ) * frequency; clusterShade += vcl_pow( ( index[0] - pixelMean ) + ( index[1] - pixelMean ), 3 ) * frequency;
clusterProminence += vcl_pow( ( index[0] - pixelMean ) + ( index[1] - pixelMean ), 4 ) * frequency; clusterProminence += vcl_pow( ( index[0] - pixelMean ) + ( index[1] - pixelMean ), 4 ) * frequency;
haralickCorrelation += index[0] * index[1] * frequency; haralickCorrelation += index[0] * index[1] * frequency;
++covectorIt; ++constVectorIt;
} }
//todo avoid division by zero also here? //todo avoid division by zero also here?
...@@ -502,11 +452,10 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage> ...@@ -502,11 +452,10 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>
template <class TInputImage, class TOutputImage> template <class TInputImage, class TOutputImage>
void void
ScalarImageToTexturesFilter<TInputImage, TOutputImage>::ComputeMeansAndVariances(GreyLevelCooccurrenceListType& frequencyVector, ScalarImageToTexturesFilter<TInputImage, TOutputImage>::
double & pixelMean, ComputeMeansAndVariances(VectorType& frequencyVector, double & pixelMean,
double & marginalMean, double & marginalMean, double & marginalDevSquared,
double & marginalDevSquared, double & pixelVariance)
double & pixelVariance)
{ {
// This function takes two passes through the histogram and two passes through // This function takes two passes through the histogram and two passes through
// an array of the same length as a histogram axis. This could probably be // an array of the same length as a histogram axis. This could probably be
...@@ -524,15 +473,15 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>::ComputeMeansAndVariances ...@@ -524,15 +473,15 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>::ComputeMeansAndVariances
// Ok, now do the first pass through the histogram to get the marginal sums // Ok, now do the first pass through the histogram to get the marginal sums
// and compute the pixel mean // and compute the pixel mean
GreyLevelCooccurrenceListConstIteratorType covectorIt; VectorConstIteratorType constVectorIt;
covectorIt = frequencyVector.begin(); constVectorIt = frequencyVector.begin();
while( covectorIt != frequencyVector.end()) while( constVectorIt != frequencyVector.end())
{ {
RelativeFrequencyType frequency = (*covectorIt).frequency; RelativeFrequencyType frequency = (*constVectorIt).frequency;
HistogramIndexType index = (*covectorIt).index; CooccurrenceIndexType index = (*constVectorIt).index;
pixelMean += index[0] * frequency; pixelMean += index[0] * frequency;
marginalSums[index[0]] += frequency; marginalSums[index[0]] += frequency;
++covectorIt; ++constVectorIt;
} }
/* Now get the mean and deviaton of the marginal sums. /* Now get the mean and deviaton of the marginal sums.
...@@ -564,13 +513,13 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>::ComputeMeansAndVariances ...@@ -564,13 +513,13 @@ ScalarImageToTexturesFilter<TInputImage, TOutputImage>::ComputeMeansAndVariances
marginalDevSquared = marginalDevSquared / m_NumberOfBinsPerAxis; marginalDevSquared = marginalDevSquared / m_NumberOfBinsPerAxis;
pixelVariance = 0; pixelVariance = 0;
covectorIt = frequencyVector.begin(); constVectorIt = frequencyVector.begin();
while( covectorIt != frequencyVector.end()) while( constVectorIt != frequencyVector.end())
{ {
RelativeFrequencyType frequency = (*covectorIt).frequency; RelativeFrequencyType frequency = (*constVectorIt).frequency;
HistogramIndexType index = (*covectorIt).index; CooccurrenceIndexType index = (*constVectorIt).index;
pixelVariance += ( index[0] - pixelMean ) * ( index[0] - pixelMean ) * frequency; pixelVariance += ( index[0] - pixelMean ) * ( index[0] - pixelMean ) * frequency;
++covectorIt; ++constVectorIt;
} }
delete[] marginalSums; delete[] marginalSums;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment