@@ -34,7 +34,9 @@ RunLengthTextureFeaturesImageFilter< TInputImage, TOutputImage >
3434 m_Max( NumericTraits<PixelType>::max() ),
3535 m_MinDistance( NumericTraits<RealType>::ZeroValue() ),
3636 m_MaxDistance( NumericTraits<RealType>::max() ),
37- m_InsidePixelValue( NumericTraits<PixelType>::OneValue() ){
37+ m_InsidePixelValue( NumericTraits<PixelType>::OneValue() ),
38+ m_Spacing( 1.0 )
39+ {
3840 this ->SetNumberOfRequiredInputs ( 1 );
3941 this ->SetNumberOfRequiredOutputs ( 1 );
4042
@@ -47,7 +49,7 @@ RunLengthTextureFeaturesImageFilter< TInputImage, TOutputImage >
4749 hood.SetRadius ( 1 );
4850
4951 // Select all "previous" neighbors that are face+edge+vertex
50- // connected to the iterated pixel. Do not include the curentInNeighborhood pixel.
52+ // connected to the iterated pixel. Do not include the currentInNeighborhood pixel.
5153 unsigned int centerIndex = hood.GetCenterNeighborhoodIndex ();
5254 OffsetVectorPointer offsets = OffsetVector::New ();
5355 for ( unsigned int d = 0 ; d < centerIndex; d++ )
@@ -78,12 +80,12 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
7880{
7981 typename TInputImage::Pointer maskPointer = TInputImage::New ();
8082 maskPointer = const_cast <TInputImage *>(this ->GetMaskImage ());
81- this ->m_DigitalisedInputImageg = InputImageType::New ();
82- this ->m_DigitalisedInputImageg ->SetRegions (this ->GetInput ()->GetRequestedRegion ());
83- this ->m_DigitalisedInputImageg ->CopyInformation (this ->GetInput ());
84- this ->m_DigitalisedInputImageg ->Allocate ();
83+ this ->m_DigitalizedInputImage = InputImageType::New ();
84+ this ->m_DigitalizedInputImage ->SetRegions (this ->GetInput ()->GetRequestedRegion ());
85+ this ->m_DigitalizedInputImage ->CopyInformation (this ->GetInput ());
86+ this ->m_DigitalizedInputImage ->Allocate ();
8587 typedef itk::ImageRegionIterator< InputImageType> IteratorType;
86- IteratorType digitIt ( this ->m_DigitalisedInputImageg , this ->m_DigitalisedInputImageg ->GetLargestPossibleRegion () );
88+ IteratorType digitIt ( this ->m_DigitalizedInputImage , this ->m_DigitalizedInputImage ->GetLargestPossibleRegion () );
8789 typedef itk::ImageRegionConstIterator< InputImageType> ConstIteratorType;
8890 ConstIteratorType inputIt ( this ->GetInput (), this ->GetInput ()->GetLargestPossibleRegion () );
8991 unsigned int binNumber;
@@ -151,14 +153,14 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
151153 }
152154 boolRegion.SetIndex (boolStart);
153155 boolRegion.SetSize (boolSize);
154- alreadyVisitedImage->CopyInformation ( this ->m_DigitalisedInputImageg );
156+ alreadyVisitedImage->CopyInformation ( this ->m_DigitalizedInputImage );
155157 alreadyVisitedImage->SetRegions ( boolRegion );
156158 alreadyVisitedImage->Allocate ();
157159
158160 // Separation of the non-boundary region that will be processed in a different way
159161 NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< TInputImage > boundaryFacesCalculator;
160162 typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< InputImageType >::FaceListType
161- faceList = boundaryFacesCalculator ( this ->m_DigitalisedInputImageg , outputRegionForThread, m_NeighborhoodRadius );
163+ faceList = boundaryFacesCalculator ( this ->m_DigitalizedInputImage , outputRegionForThread, m_NeighborhoodRadius );
162164 typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< InputImageType >::FaceListType::iterator fit = faceList.begin ();
163165
164166 // Declaration of the variables useful to iterate over the all image region
@@ -169,14 +171,14 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
169171 // Declaration of the variables useful to iterate over the all the offsets
170172 OffsetType offset;
171173 unsigned int totalNumberOfRuns;
172- unsigned int **hist = new unsigned int *[m_NumberOfBinsPerAxis];
173- for (unsigned int a = 0 ; a < m_NumberOfBinsPerAxis; a++ )
174+ unsigned int **histogram = new unsigned int *[m_NumberOfBinsPerAxis];
175+ for (unsigned int axis = 0 ; axis < m_NumberOfBinsPerAxis; ++axis )
174176 {
175- hist[a ] = new unsigned int [m_NumberOfBinsPerAxis];
177+ histogram[axis ] = new unsigned int [m_NumberOfBinsPerAxis];
176178 }
177179
178180 // Declaration of the variables useful to iterate over the all neighborhood region
179- PixelType curentInNeighborhoodPixelIntensity ;
181+ PixelType currentInNeighborhoodPixelIntensity ;
180182
181183 // Declaration of the variables useful to iterate over the run
182184 PixelType pixelIntensity ( NumericTraits<PixelType>::ZeroValue () );
@@ -188,7 +190,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
188190 // / ***** Non-boundary Region *****
189191 for (; fit != faceList.end (); ++fit )
190192 {
191- NeighborhoodIteratorType inputNIt (m_NeighborhoodRadius, this ->m_DigitalisedInputImageg , *fit );
193+ NeighborhoodIteratorType inputNIt (m_NeighborhoodRadius, this ->m_DigitalizedInputImage , *fit );
192194 typedef itk::ImageRegionIterator< OutputImageType> IteratorType;
193195 IteratorType outputIt ( outputPtr, *fit );
194196
@@ -208,7 +210,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
208210 {
209211 for (unsigned int b = 0 ; b < m_NumberOfBinsPerAxis; b++)
210212 {
211- hist [a][b] = 0 ;
213+ histogram [a][b] = 0 ;
212214 }
213215 }
214216 totalNumberOfRuns = 0 ;
@@ -221,10 +223,10 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
221223 // Iteration over the all neighborhood region
222224 for (NeighborIndexType nb = 0 ; nb<inputNIt.Size (); ++nb)
223225 {
224- curentInNeighborhoodPixelIntensity = inputNIt.GetPixel (nb);
226+ currentInNeighborhoodPixelIntensity = inputNIt.GetPixel (nb);
225227 tempOffset = inputNIt.GetOffset (nb);
226228 // Checking if the value is out-of-bounds or is outside the mask.
227- if ( curentInNeighborhoodPixelIntensity < 0 || // The pixel is outside of the mask or outside of bounds
229+ if ( currentInNeighborhoodPixelIntensity < 0 || // The pixel is outside of the mask or outside of bounds
228230 alreadyVisitedImage->GetPixel ( boolCurentInNeighborhoodIndex + tempOffset) )
229231 {
230232 continue ;
@@ -251,7 +253,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
251253 // Special attention paid to boundaries of bins.
252254 // For the last bin, it is left close and right close (following the previous
253255 // gerrit patch). For all other bins, the bin is left close and right open.
254- if ( pixelIntensity == curentInNeighborhoodPixelIntensity )
256+ if ( pixelIntensity == currentInNeighborhoodPixelIntensity )
255257 {
256258 alreadyVisitedImage->SetPixel ( boolCurentInNeighborhoodIndex + iteratedOffset, true );
257259 pixelDistance++;
@@ -264,20 +266,26 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
264266 }
265267 }
266268 // Increase the corresponding bin in the histogram
267- this ->IncreaseHistogram (hist , totalNumberOfRuns,
268- curentInNeighborhoodPixelIntensity ,
269+ this ->IncreaseHistogram (histogram , totalNumberOfRuns,
270+ currentInNeighborhoodPixelIntensity ,
269271 offset, pixelDistance);
270272 }
271273 }
272274 // Compute the run length features
273- this ->ComputeFeatures ( hist , totalNumberOfRuns, outputPixel);
275+ this ->ComputeFeatures ( histogram , totalNumberOfRuns, outputPixel);
274276 outputIt.Set (outputPixel);
275277
276278 progress.CompletedPixel ();
277279 ++inputNIt;
278280 ++outputIt;
279281 }
280282 }
283+
284+ for (unsigned int axis = 0 ; axis < m_NumberOfBinsPerAxis; ++axis)
285+ {
286+ delete histogram[axis];
287+ }
288+ delete histogram;
281289}
282290
283291template <typename TInputImage, typename TOutputImage>
@@ -387,8 +395,8 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
387395template <typename TInputImage, typename TOutputImage>
388396void
389397RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
390- ::IncreaseHistogram (unsigned int **hist , unsigned int &totalNumberOfRuns,
391- const PixelType &curentInNeighborhoodPixelIntensity ,
398+ ::IncreaseHistogram (unsigned int **histogram , unsigned int &totalNumberOfRuns,
399+ const PixelType ¤tInNeighborhoodPixelIntensity ,
392400 const OffsetType &offset, const unsigned int &pixelDistance)
393401{
394402 float offsetDistance = 0 ;
@@ -404,14 +412,14 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
404412 if (offsetDistanceBin < static_cast < int >( m_NumberOfBinsPerAxis ))
405413 {
406414 totalNumberOfRuns++;
407- hist[curentInNeighborhoodPixelIntensity ][offsetDistanceBin]++;
415+ histogram[currentInNeighborhoodPixelIntensity ][offsetDistanceBin]++;
408416 }
409417}
410418
411419template <typename TInputImage, typename TOutputImage>
412420void
413421RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
414- ::ComputeFeatures ( unsigned int **hist ,const unsigned int &totalNumberOfRuns,
422+ ::ComputeFeatures ( unsigned int **histogram ,const unsigned int &totalNumberOfRuns,
415423 typename TOutputImage::PixelType &outputPixel)
416424{
417425 OutputRealType shortRunEmphasis = NumericTraits<OutputRealType>::ZeroValue ();
@@ -434,7 +442,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
434442 {
435443 for (unsigned int b = 0 ; b < m_NumberOfBinsPerAxis; b++)
436444 {
437- OutputRealType frequency = hist [a][b];
445+ OutputRealType frequency = histogram [a][b];
438446 if ( Math::ExactlyEquals (frequency, NumericTraits<OutputRealType>::ZeroValue ()) )
439447 {
440448 continue ;
@@ -502,31 +510,31 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
502510{
503511 Superclass::PrintSelf ( os, indent );
504512
505- itkPrintSelfObjectMacro ( DigitalisedInputImageg );
513+ itkPrintSelfObjectMacro ( DigitalizedInputImage );
506514
507- os << indent << " NeighborhoodRadius"
515+ os << indent << " NeighborhoodRadius: "
508516 << static_cast < typename NumericTraits<
509517 NeighborhoodRadiusType >::PrintType >( m_NeighborhoodRadius ) << std::endl;
510518
511519 itkPrintSelfObjectMacro ( Offsets );
512520
513- os << indent << " NumberOfBinsPerAxis" << m_NumberOfBinsPerAxis << std::endl;
514- os << indent << " Min"
521+ os << indent << " NumberOfBinsPerAxis: " << m_NumberOfBinsPerAxis << std::endl;
522+ os << indent << " Min: "
515523 << static_cast < typename NumericTraits< PixelType >::PrintType >( m_Min )
516524 << std::endl;
517- os << indent << " Max"
525+ os << indent << " Max: "
518526 << static_cast < typename NumericTraits< PixelType >::PrintType >( m_Max )
519527 << std::endl;
520- os << indent << " MinDistance"
528+ os << indent << " MinDistance: "
521529 << static_cast < typename NumericTraits< RealType >::PrintType >(
522530 m_MinDistance ) << std::endl;
523- os << indent << " MaxDistance"
531+ os << indent << " MaxDistance: "
524532 << static_cast < typename NumericTraits< RealType >::PrintType >(
525533 m_MaxDistance ) << std::endl;
526- os << indent << " InsidePixelValue"
534+ os << indent << " InsidePixelValue: "
527535 << static_cast < typename NumericTraits< PixelType >::PrintType >(
528536 m_InsidePixelValue ) << std::endl;
529- os << indent << " Spacing"
537+ os << indent << " Spacing: "
530538 << static_cast < typename NumericTraits<
531539 typename TInputImage::SpacingType >::PrintType >( m_Spacing ) << std::endl;
532540}
0 commit comments