Skip to content

Commit 3aad655

Browse files
authored
Merge pull request #17 from blowekamp/StyleAndPerformanceTweaks
Style and performance tweaks
2 parents c103e8e + 39bb122 commit 3aad655

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

include/itkCoocurrenceTextureFeaturesImageFilter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ class ITK_TEMPLATE_EXPORT CoocurrenceTextureFeaturesImageFilter:public ImageToIm
209209
virtual ~CoocurrenceTextureFeaturesImageFilter() {}
210210

211211
bool IsInsideNeighborhood(const OffsetType &iteratedOffset);
212-
void ComputeFeatures( vnl_matrix<unsigned int> &hist, const unsigned int &totalNumberOfFreq,
212+
void ComputeFeatures(const vnl_matrix<unsigned int> &hist, const unsigned int totalNumberOfFreq,
213213
typename TOutputImage::PixelType &outputPixel);
214-
void ComputeMeansAndVariances(vnl_matrix<unsigned int> &hist,
215-
const unsigned int &totalNumberOfFreq,
214+
void ComputeMeansAndVariances(const vnl_matrix<unsigned int> &hist,
215+
const unsigned int totalNumberOfFreq,
216216
double & pixelMean,
217217
double & marginalMean,
218218
double & marginalDevSquared,

include/itkCoocurrenceTextureFeaturesImageFilter.hxx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ CoocurrenceTextureFeaturesImageFilter< TInputImage, TOutputImage >
3232
m_NumberOfBinsPerAxis( itkGetStaticConstMacro( DefaultBinsPerAxis ) ),
3333
m_Min( NumericTraits<PixelType>::NonpositiveMin() ),
3434
m_Max( NumericTraits<PixelType>::max() ),
35-
m_InsidePixelValue( NumericTraits<PixelType>::OneValue() ){
35+
m_InsidePixelValue( NumericTraits<PixelType>::OneValue() )
36+
{
3637
this->SetNumberOfRequiredInputs( 1 );
3738
this->SetNumberOfRequiredOutputs( 1 );
3839

@@ -76,7 +77,7 @@ void
7677
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
7778
::BeforeThreadedGenerateData()
7879
{
79-
InputImageType * maskPointer = const_cast<TInputImage *>(this->GetMaskImage());
80+
const InputImageType * maskPointer = this->GetMaskImage();
8081
this->m_DigitalisedInputImageg = InputImageType::New();
8182
this->m_DigitalisedInputImageg->SetRegions(this->GetInput()->GetRequestedRegion());
8283
this->m_DigitalisedInputImageg->CopyInformation(this->GetInput());
@@ -181,13 +182,8 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
181182
continue;
182183
}
183184
// Initialisation of the histogram
184-
for(unsigned int a = 0; a < m_NumberOfBinsPerAxis; a++)
185-
{
186-
for(unsigned int b = 0; b < m_NumberOfBinsPerAxis; b++)
187-
{
188-
hist[a][b] = 0;
189-
}
190-
}
185+
hist.fill(0);
186+
191187
totalNumberOfFreq = 0;
192188
// Iteration over all the offsets
193189
for( offsets = m_Offsets->Begin(); offsets != m_Offsets->End(); ++offsets )
@@ -313,7 +309,7 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
313309
template<typename TInputImage, typename TOutputImage>
314310
void
315311
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
316-
::ComputeFeatures( vnl_matrix<unsigned int> &hist,const unsigned int &totalNumberOfFreq,
312+
::ComputeFeatures( const vnl_matrix<unsigned int> &hist, const unsigned int totalNumberOfFreq,
317313
typename TOutputImage::PixelType &outputPixel)
318314
{
319315
// Now get the various means and variances. This is takes two passes
@@ -390,8 +386,8 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
390386
template<typename TInputImage, typename TOutputImage>
391387
void
392388
CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
393-
::ComputeMeansAndVariances(vnl_matrix<unsigned int> &hist,
394-
const unsigned int &totalNumberOfFreq,
389+
::ComputeMeansAndVariances(const vnl_matrix<unsigned int> &hist,
390+
const unsigned int totalNumberOfFreq,
395391
double & pixelMean,
396392
double & marginalMean,
397393
double & marginalDevSquared,
@@ -417,7 +413,6 @@ CoocurrenceTextureFeaturesImageFilter<TInputImage, TOutputImage>
417413
{
418414
for(unsigned int b = 0; b < m_NumberOfBinsPerAxis; b++)
419415
{
420-
int k = hist[a][b];
421416
float frequency = hist[a][b] / (float)totalNumberOfFreq;
422417
pixelMean += a * frequency;
423418
marginalSums[a] += frequency;

0 commit comments

Comments
 (0)