@@ -52,7 +52,7 @@ RunLengthTextureFeaturesImageFilter< TInputImage, TOutputImage >
5252 // connected to the iterated pixel. Do not include the currentInNeighborhood pixel.
5353 unsigned int centerIndex = hood.GetCenterNeighborhoodIndex ();
5454 OffsetVectorPointer offsets = OffsetVector::New ();
55- for ( unsigned int d = 0 ; d < centerIndex; d++ )
55+ for ( unsigned int d = 0 ; d < centerIndex; ++d )
5656 {
5757 OffsetType offset = hood.GetOffset ( d );
5858 offsets->push_back ( offset );
@@ -145,7 +145,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
145145 IndexType boolCurentInNeighborhoodIndex;
146146 typedef Image<bool , TInputImage::ImageDimension> BoolImageType;
147147 typename BoolImageType::Pointer alreadyVisitedImage = BoolImageType::New ();
148- for ( unsigned int i = 0 ; i < this ->m_NeighborhoodRadius .Dimension ; i++ )
148+ for ( unsigned int i = 0 ; i < this ->m_NeighborhoodRadius .Dimension ; ++i )
149149 {
150150 boolSize[i] = this ->m_NeighborhoodRadius [i]*2 + 1 ;
151151 boolStart[i] = 0 ;
@@ -206,9 +206,9 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
206206 continue ;
207207 }
208208 // Initialisation of the histogram
209- for (unsigned int a = 0 ; a < m_NumberOfBinsPerAxis; a++ )
209+ for (unsigned int a = 0 ; a < m_NumberOfBinsPerAxis; ++a )
210210 {
211- for (unsigned int b = 0 ; b < m_NumberOfBinsPerAxis; b++ )
211+ for (unsigned int b = 0 ; b < m_NumberOfBinsPerAxis; ++b )
212212 {
213213 histogram[a][b] = 0 ;
214214 }
@@ -256,7 +256,7 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
256256 if ( pixelIntensity == currentInNeighborhoodPixelIntensity )
257257 {
258258 alreadyVisitedImage->SetPixel ( boolCurentInNeighborhoodIndex + iteratedOffset, true );
259- pixelDistance++ ;
259+ ++pixelDistance ;
260260 iteratedOffset += offset;
261261 insideNeighborhood = this ->IsInsideNeighborhood (iteratedOffset);
262262 }
@@ -266,9 +266,11 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
266266 }
267267 }
268268 // Increase the corresponding bin in the histogram
269+
269270 this ->IncreaseHistogram (histogram, totalNumberOfRuns,
270- currentInNeighborhoodPixelIntensity,
271- offset, pixelDistance);
271+ currentInNeighborhoodPixelIntensity,
272+ offset, pixelDistance);
273+
272274 }
273275 }
274276 // Compute the run length features
@@ -283,9 +285,9 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
283285
284286 for (unsigned int axis = 0 ; axis < m_NumberOfBinsPerAxis; ++axis)
285287 {
286- delete histogram[axis];
288+ delete[] histogram[axis];
287289 }
288- delete histogram;
290+ delete[] histogram;
289291}
290292
291293template <typename TInputImage, typename TOutputImage>
@@ -405,14 +407,12 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
405407 offsetDistance += (offset[i]*m_Spacing[i])*(offset[i]*m_Spacing[i]);
406408 }
407409 offsetDistance = std::sqrt (offsetDistance);
408-
409410 int offsetDistanceBin = static_cast < int >(( offsetDistance*pixelDistance - m_MinDistance)/
410411 ( (m_MaxDistance - m_MinDistance) / (float )m_NumberOfBinsPerAxis ));
411-
412- if (offsetDistanceBin < static_cast < int >( m_NumberOfBinsPerAxis ))
412+ if (offsetDistanceBin < static_cast < int >( m_NumberOfBinsPerAxis ) && offsetDistanceBin >= 0 )
413413 {
414- totalNumberOfRuns++ ;
415- histogram[currentInNeighborhoodPixelIntensity][offsetDistanceBin]++ ;
414+ ++totalNumberOfRuns ;
415+ ++ histogram[currentInNeighborhoodPixelIntensity][offsetDistanceBin];
416416 }
417417}
418418
@@ -438,9 +438,9 @@ RunLengthTextureFeaturesImageFilter<TInputImage, TOutputImage>
438438 vnl_vector<double > runLengthNonuniformityVector (
439439 m_NumberOfBinsPerAxis, 0.0 );
440440
441- for (unsigned int a = 0 ; a < m_NumberOfBinsPerAxis; a++ )
441+ for (unsigned int a = 0 ; a < m_NumberOfBinsPerAxis; ++a )
442442 {
443- for (unsigned int b = 0 ; b < m_NumberOfBinsPerAxis; b++ )
443+ for (unsigned int b = 0 ; b < m_NumberOfBinsPerAxis; ++b )
444444 {
445445 OutputRealType frequency = histogram[a][b];
446446 if ( Math::ExactlyEquals (frequency, NumericTraits<OutputRealType>::ZeroValue ()) )
0 commit comments