Skip to content

Commit 0614657

Browse files
committed
BUG: Rename and replace min/max setter with separate setter methods
For CoocurrenceTextureFeaturesImageFilter: m_Min->m_HistogramMaximum respectfully in the and similarly for the maximum. For RunLengthTextureFeaturesImageFilter: m_Min -> m_HistogramValueMinimum m_MinDistance -> m_HistogramDistanceMinimum and similarly for the maximum. Add the properly named Set and Get accessors methods according to ITK convention. ITK standards are for each parameter or ivar to have a separate set method. The exists methods which set a min/max pair now call the standard macro based set methods.
1 parent 2fed5dc commit 0614657

16 files changed

+108
-130
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace Statistics
4545
*
4646
* Template Parameters:
4747
* -# The input image type: a N dimensional image where the pixel type MUST be integer.
48-
* -# The output image type: a N dimensional image where the pixel type MUST be a vector of floating points or an ImageVector.
48+
* -# The output image type: a N dimensional image where the pixel type MUST be a vector of floating points or a VectorImage.
4949
*
5050
* Inputs and parameters:
5151
* -# An image
@@ -170,17 +170,13 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
170170
/** Get number of histogram bins along each axis */
171171
itkGetConstMacro( NumberOfBinsPerAxis, unsigned int );
172172

173-
/**
174-
* Set the min and max (inclusive) pixel value that will be used in
175-
* generating the histogram.
176-
*/
177-
void SetPixelValueMinMax( PixelType min, PixelType max );
173+
/** Get the max pixel value defining one dimension of the joint histogram. */
174+
itkGetConstMacro( HistogramMaximum, PixelType );
175+
itkSetMacro( HistogramMaximum, PixelType);
178176

179177
/** Get the min pixel value defining one dimension of the joint histogram. */
180-
itkGetConstMacro( Min, PixelType );
181-
182-
/** Get the max pixel value defining one dimension of the joint histogram. */
183-
itkGetConstMacro( Max, PixelType );
178+
itkGetConstMacro( HistogramMinimum, PixelType );
179+
itkSetMacro( HistogramMinimum, PixelType);
184180

185181
/**
186182
* Set the pixel value of the mask that should be considered "inside" the
@@ -236,8 +232,8 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
236232
NeighborhoodRadiusType m_NeighborhoodRadius;
237233
OffsetVectorPointer m_Offsets;
238234
unsigned int m_NumberOfBinsPerAxis;
239-
PixelType m_Min;
240-
PixelType m_Max;
235+
PixelType m_HistogramMinimum;
236+
PixelType m_HistogramMaximum;
241237
PixelType m_InsidePixelValue;
242238
bool m_Normalize;
243239

include/itkCoocurrenceTextureFeaturesImageFilter.hxx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ template< typename TInputImage, typename TOutputImage>
3131
CoocurrenceTextureFeaturesImageFilter< TInputImage, TOutputImage >
3232
::CoocurrenceTextureFeaturesImageFilter() :
3333
m_NumberOfBinsPerAxis( itkGetStaticConstMacro( DefaultBinsPerAxis ) ),
34-
m_Min( NumericTraits<PixelType>::NonpositiveMin() ),
35-
m_Max( NumericTraits<PixelType>::max() ),
34+
m_HistogramMinimum( NumericTraits<PixelType>::NonpositiveMin() ),
35+
m_HistogramMaximum( NumericTraits<PixelType>::max() ),
3636
m_InsidePixelValue( NumericTraits<PixelType>::OneValue() )
3737
{
3838
this->SetNumberOfRequiredInputs( 1 );
@@ -89,7 +89,7 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
8989
input->Graft(const_cast<TInputImage *>(this->GetInput()));
9090

9191
typedef PreProcessingFunctor PPFType;
92-
PPFType ppf(m_NumberOfBinsPerAxis, m_InsidePixelValue, m_Min, m_Max);
92+
PPFType ppf(m_NumberOfBinsPerAxis, m_InsidePixelValue, m_HistogramMinimum, m_HistogramMaximum);
9393

9494
typedef BinaryFunctorImageFilter< MaskImageType, InputImageType, InputImageType, PPFType> BinaryFunctorType;
9595
typename BinaryFunctorType::Pointer functorF = BinaryFunctorType::New();
@@ -264,20 +264,6 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
264264
}
265265
}
266266

267-
268-
template<typename TInputImage, typename TOutputImage>
269-
void
270-
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
271-
::SetPixelValueMinMax( PixelType min, PixelType max )
272-
{
273-
if( this->m_Min != min || this->m_Max != max )
274-
{
275-
this->m_Min = min;
276-
this->m_Max = max;
277-
this->Modified();
278-
}
279-
}
280-
281267
template<typename TInputImage, typename TOutputImage>
282268
bool
283269
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
@@ -468,10 +454,10 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
468454

469455
os << indent << "NumberOfBinsPerAxis: " << m_NumberOfBinsPerAxis << std::endl;
470456
os << indent << "Min: "
471-
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_Min )
457+
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_HistogramMinimum )
472458
<< std::endl;
473459
os << indent << "Max: "
474-
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_Max )
460+
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_HistogramMaximum )
475461
<< std::endl;
476462
os << indent << "InsidePixelValue: "
477463
<< static_cast< typename NumericTraits< PixelType >::PrintType >(

include/itkRunLengthTextureFeaturesImageFilter.h

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ namespace Statistics
3434
* This filter computes a N-D image where each voxel will contain
3535
* a vector of up to 10 scalars representing the run length features
3636
* (of the specified neighborhood) from a N-D scalar image.
37-
* The run length features are computed for each spatial
38-
* direction and averaged afterward.
37+
* The run length features are computed from joint histograms of
38+
* pixel intensities and distance (run length) per spatial direction
39+
* then averaged afterward.
40+
*
3941
* The result obtained is a possible texture description. See the following references.
4042
* M. M. Galloway. Texture analysis using gray level run lengths. Computer
4143
* Graphics and Image Processing, 4:172-179, 1975.
@@ -50,7 +52,7 @@ namespace Statistics
5052
*
5153
* Template Parameters:
5254
* -# The input image type: a N dimensional image where the pixel type MUST be integer.
53-
* -# The output image type: a N dimensional image where the pixel type MUST be a vector of floating points or an ImageVector.
55+
* -# The output image type: a N dimensional image where the pixel type MUST be a vector of floating points or a VectorImage.
5456
*
5557
* Inputs and parameters:
5658
* -# An image
@@ -62,10 +64,12 @@ namespace Statistics
6264
* -# The set of directions (offsets) to average across. (Optional, defaults to
6365
* {(-1, 0), (-1, -1), (0, -1), (1, -1)} for 2D images and scales analogously
6466
* for ND images.)
65-
* -# The pixel intensity range over which the features will be calculated.
66-
* (Optional, defaults to the full dynamic range of the pixel type.)
67-
* -# The distance range over which the features will be calculated.
68-
* (Optional, defaults to the full dynamic range of double type.)
67+
* -# The pixel intensity range for the joint histogram over which the
68+
* features will be calculated. (Optional, defaults to the full
69+
* dynamic range of the pixel type.)
70+
* -# The distance range for the joint histogram over which the
71+
* features will be calculated. (Optional, defaults to the full
72+
* dynamic range of double type.)
6973
* -# The size of the neighborhood radius. (Optional, defaults to 2.)
7074
*
7175
* Recommendations:
@@ -175,33 +179,30 @@ class ITK_TEMPLATE_EXPORT RunLengthTextureFeaturesImageFilter:public ImageToImag
175179
/** Get number of histogram bins along each axis */
176180
itkGetConstMacro( NumberOfBinsPerAxis, unsigned int );
177181

178-
/**
179-
* Set the min and max (inclusive) pixel value that will be used in
180-
* generating the histogram.
181-
*/
182-
void SetPixelValueMinMax( PixelType min, PixelType max );
182+
/** Set/Get the minimum (inclusive) pixel value defining one dimension of the joint
183+
* value distance histogram. */
184+
itkGetConstMacro( HistogramValueMinimum, PixelType );
185+
itkSetMacro( HistogramValueMinimum, PixelType);
183186

184-
/** Get the min pixel value defining one dimension of the joint histogram. */
185-
itkGetConstMacro( Min, PixelType );
187+
/** Set/Get the maximum pixel value defining one dimension of the joint
188+
* value distance histogram. */
189+
itkGetConstMacro( HistogramValueMaximum, PixelType );
190+
itkSetMacro( HistogramValueMaximum, PixelType);
186191

187-
/** Get the max pixel value defining one dimension of the joint histogram. */
188-
itkGetConstMacro( Max, PixelType );
189192

190193
/**
191-
* Set the min and max (inclusive) pixel value that will be used in
192-
* generating the histogram.
194+
* Set/Get the minimum (inclusive) run length distance in physical
195+
* space that will be used in generating the joint value distance histogram.
193196
*/
194-
void SetDistanceValueMinMax( RealType min, RealType max );
197+
itkGetConstMacro( HistogramDistanceMinimum, RealType );
198+
itkSetMacro( HistogramDistanceMinimum, RealType);
195199

196-
/**
197-
* Get the min distance value defining one dimension of the joint histogram.
198-
*/
199-
itkGetConstMacro( MinDistance, RealType );
200-
201-
/**
202-
* Get the max distance value defining one dimension of the joint histogram.
200+
/**
201+
* Set/Get the maximum run length distance in physical
202+
* space that will be used in generating the joint value distance histogram.
203203
*/
204-
itkGetConstMacro( MaxDistance, RealType );
204+
itkGetConstMacro( HistogramDistanceMaximum, RealType );
205+
itkSetMacro( HistogramDistanceMaximum, RealType);
205206

206207
/**
207208
* Set the pixel value of the mask that should be considered "inside" the
@@ -247,10 +248,10 @@ class ITK_TEMPLATE_EXPORT RunLengthTextureFeaturesImageFilter:public ImageToImag
247248
NeighborhoodRadiusType m_NeighborhoodRadius;
248249
OffsetVectorPointer m_Offsets;
249250
unsigned int m_NumberOfBinsPerAxis;
250-
PixelType m_Min;
251-
PixelType m_Max;
252-
RealType m_MinDistance;
253-
RealType m_MaxDistance;
251+
PixelType m_HistogramValueMinimum;
252+
PixelType m_HistogramValueMaximum;
253+
RealType m_HistogramDistanceMinimum;
254+
RealType m_HistogramDistanceMaximum;
254255
PixelType m_InsidePixelValue;
255256
typename TInputImage::SpacingType m_Spacing;
256257
};

include/itkRunLengthTextureFeaturesImageFilter.hxx

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ template< typename TInputImage, typename TOutputImage>
3030
RunLengthTextureFeaturesImageFilter< TInputImage, TOutputImage >
3131
::RunLengthTextureFeaturesImageFilter() :
3232
m_NumberOfBinsPerAxis( itkGetStaticConstMacro( DefaultBinsPerAxis ) ),
33-
m_Min( NumericTraits<PixelType>::NonpositiveMin() ),
34-
m_Max( NumericTraits<PixelType>::max() ),
35-
m_MinDistance( NumericTraits<RealType>::ZeroValue() ),
36-
m_MaxDistance( NumericTraits<RealType>::max() ),
33+
m_HistogramValueMinimum( NumericTraits<PixelType>::NonpositiveMin() ),
34+
m_HistogramValueMaximum( NumericTraits<PixelType>::max() ),
35+
m_HistogramDistanceMinimum( NumericTraits<RealType>::ZeroValue() ),
36+
m_HistogramDistanceMaximum( NumericTraits<RealType>::max() ),
3737
m_InsidePixelValue( NumericTraits<PixelType>::OneValue() ),
3838
m_Spacing( 1.0 )
3939
{
@@ -95,13 +95,13 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
9595
{
9696
digitIt.Set(-10);
9797
}
98-
else if(inputIt.Get() < this->m_Min || inputIt.Get() >= this->m_Max)
98+
else if(inputIt.Get() < this->m_HistogramValueMinimum || inputIt.Get() >= this->m_HistogramValueMinimum)
9999
{
100100
digitIt.Set(-1);
101101
}
102102
else
103103
{
104-
binNumber = ( inputIt.Get() - m_Min)/( (m_Max - m_Min) / (float)m_NumberOfBinsPerAxis );
104+
binNumber = ( inputIt.Get() - m_HistogramValueMinimum)/( (m_HistogramValueMaximum - m_HistogramValueMinimum) / (float)m_NumberOfBinsPerAxis );
105105
digitIt.Set(binNumber);
106106
}
107107
++inputIt;
@@ -328,32 +328,6 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
328328
return static_cast<const InputImageType *>( this->ProcessObject::GetInput( 1 ) );
329329
}
330330

331-
template<typename TInputImage, typename TOutputImage>
332-
void
333-
RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
334-
::SetPixelValueMinMax( PixelType min, PixelType max )
335-
{
336-
if( this->m_Min != min || this->m_Max != max )
337-
{
338-
this->m_Min = min;
339-
this->m_Max = max;
340-
this->Modified();
341-
}
342-
}
343-
344-
template<typename TInputImage, typename TOutputImage>
345-
void
346-
RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
347-
::SetDistanceValueMinMax( RealType min, RealType max )
348-
{
349-
if( Math::NotExactlyEquals(this->m_MinDistance, min) || Math::NotExactlyEquals(this->m_MaxDistance, max) )
350-
{
351-
this->m_MinDistance = min;
352-
this->m_MaxDistance = max;
353-
this->Modified();
354-
}
355-
}
356-
357331
template<typename TInputImage, typename TOutputImage>
358332
void
359333
RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
@@ -409,8 +383,8 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
409383
offsetDistance += (offset[i]*m_Spacing[i])*(offset[i]*m_Spacing[i]);
410384
}
411385
offsetDistance = std::sqrt(offsetDistance);
412-
int offsetDistanceBin = static_cast< int>(( offsetDistance*pixelDistance - m_MinDistance)/
413-
( (m_MaxDistance - m_MinDistance) / (float)m_NumberOfBinsPerAxis ));
386+
int offsetDistanceBin = static_cast< int>(( offsetDistance*pixelDistance - m_HistogramDistanceMinimum)/
387+
( (m_HistogramDistanceMaximum - m_HistogramDistanceMinimum) / (float)m_NumberOfBinsPerAxis ));
414388
if (offsetDistanceBin < static_cast< int >( m_NumberOfBinsPerAxis ) && offsetDistanceBin >= 0)
415389
{
416390
++totalNumberOfRuns;
@@ -522,17 +496,17 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
522496

523497
os << indent << "NumberOfBinsPerAxis: " << m_NumberOfBinsPerAxis << std::endl;
524498
os << indent << "Min: "
525-
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_Min )
499+
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_HistogramValueMinimum )
526500
<< std::endl;
527501
os << indent << "Max: "
528-
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_Max )
502+
<< static_cast< typename NumericTraits< PixelType >::PrintType >( m_HistogramValueMaximum )
529503
<< std::endl;
530504
os << indent << "MinDistance: "
531505
<< static_cast< typename NumericTraits< RealType >::PrintType >(
532-
m_MinDistance ) << std::endl;
506+
m_HistogramDistanceMinimum ) << std::endl;
533507
os << indent << "MaxDistance: "
534508
<< static_cast< typename NumericTraits< RealType >::PrintType >(
535-
m_MaxDistance ) << std::endl;
509+
m_HistogramDistanceMaximum ) << std::endl;
536510
os << indent << "InsidePixelValue: "
537511
<< static_cast< typename NumericTraits< PixelType >::PrintType >(
538512
m_InsidePixelValue ) << std::endl;

test/CoocurrenceTextureFeaturesImageFilterInstantiationTest.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ int CoocurrenceTextureFeaturesImageFilterInstantiationTest( int argc, char *argv
7979

8080
FilterType::PixelType min = -62;
8181
FilterType::PixelType max = 2456;
82-
filter->SetPixelValueMinMax( min, max );
83-
TEST_SET_GET_VALUE( min, filter->GetMin() );
84-
TEST_SET_GET_VALUE( max, filter->GetMax() );
82+
filter->SetHistogramMinimum( min );
83+
filter->SetHistogramMaximum( max );
84+
TEST_SET_GET_VALUE( min, filter->GetHistogramMinimum() );
85+
TEST_SET_GET_VALUE( max, filter->GetHistogramMaximum() );
8586

8687
NeighborhoodType::SizeValueType neighborhoodRadius = 3;
8788
NeighborhoodType hood;

test/CoocurrenceTextureFeaturesImageFilterTest.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ int CoocurrenceTextureFeaturesImageFilterTest( int argc, char *argv[] )
7373

7474
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
7575
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
76-
filter->SetPixelValueMinMax( pixelValueMin, pixelValueMax );
76+
filter->SetHistogramMinimum( pixelValueMin );
77+
filter->SetHistogramMaximum( pixelValueMax );
7778

7879
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
7980
NeighborhoodType hood;

test/CoocurrenceTextureFeaturesImageFilterTestSeparateFeatures.cxx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ int CoocurrenceTextureFeaturesImageFilterTestSeparateFeatures( int argc, char *a
7878
unsigned int numberOfBinsPerAxis = std::atoi( argv[4] );
7979
filter->SetNumberOfBinsPerAxis( numberOfBinsPerAxis );
8080

81-
FilterType::PixelType min = std::atof( argv[5] );
82-
FilterType::PixelType max = std::atof( argv[6] );
83-
filter->SetPixelValueMinMax( min, max );
81+
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
82+
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
83+
filter->SetHistogramMinimum( pixelValueMin );
84+
filter->SetHistogramMaximum( pixelValueMax );
85+
8486

8587
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
8688
NeighborhoodType hood;

test/CoocurrenceTextureFeaturesImageFilterTestVectorImageSeparateFeatures.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ int CoocurrenceTextureFeaturesImageFilterTestVectorImageSeparateFeatures( int ar
7979

8080
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
8181
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
82-
filter->SetPixelValueMinMax( pixelValueMin, pixelValueMax );
82+
filter->SetHistogramMinimum( pixelValueMin );
83+
filter->SetHistogramMaximum( pixelValueMax );
8384

8485
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
8586
NeighborhoodType hood;

test/CoocurrenceTextureFeaturesImageFilterTestWithVectorImage.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ int CoocurrenceTextureFeaturesImageFilterTestWithVectorImage( int argc, char *ar
7979

8080
FilterType::PixelType pixelValueMin = std::atof( argv[5] );
8181
FilterType::PixelType pixelValueMax = std::atof( argv[6] );
82-
filter->SetPixelValueMinMax( pixelValueMin, pixelValueMax );
82+
filter->SetHistogramMinimum( pixelValueMin );
83+
filter->SetHistogramMaximum( pixelValueMax );
8384

8485
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[7] );
8586
NeighborhoodType hood;

test/CoocurrenceTextureFeaturesImageFilterTestWithoutMask.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ int CoocurrenceTextureFeaturesImageFilterTestWithoutMask( int argc, char *argv[]
7272

7373
FilterType::PixelType pixelValueMin = std::atof( argv[4] );
7474
FilterType::PixelType pixelValueMax = std::atof( argv[5] );
75-
filter->SetPixelValueMinMax( pixelValueMin, pixelValueMax );
75+
filter->SetHistogramMinimum( pixelValueMin );
76+
filter->SetHistogramMaximum( pixelValueMax );
7677

7778
NeighborhoodType::SizeValueType neighborhoodRadius = std::atoi( argv[6] );
7879
NeighborhoodType hood;

0 commit comments

Comments
 (0)