[Insight-users] Couple small bug fixes I'd like to contribute!

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Jun 18 10:05:41 EDT 2008


Hello!

I have run into a couple small bug in ITK and posted the problems and  
solution, but I have not seen the fixes make it into the repository.  
Is there a better way to do post fixes then I have been? Should I post  
diffs?

I have discovered a divide by zero error in the CovarianceCalculator  
classes:

Something to the effect of:

if (frequency == 0) {
  ++iter;
  continue;
}

needs to be added early on in this loop in the  
CovarianceCalculator::ComputeCovarianceWithoutGivenMean method.


  //
  // fills the lower triangle and the diagonal cells in the covariance  
matrix
   while (iter != end)
     {
     frequency = iter.GetFrequency() ;
     totalFrequency += frequency ;
     measurements = iter.GetMeasurementVector() ;
     for ( i = 0 ; i < measurementVectorSize ; ++i )
       {
       diff[i] = measurements[i] - (*m_InternalMean)[i] ;
       }

     // updates the mean vector
     double tempWeight = frequency / totalFrequency ;
     for ( i = 0 ; i < measurementVectorSize ; ++i )
       {
       (*m_InternalMean)[i] += tempWeight * diff[i] ;
       }

     // updates the covariance matrix
     tempWeight = tempWeight * ( totalFrequency - frequency ) ;
     for ( row = 0; row < measurementVectorSize ; row++ )
       {
       for ( col = 0; col < row + 1 ; col++)
         {
         m_Output(row,col) +=
           tempWeight * diff[row] * diff[col] ;
         }
       }
     ++iter ;
     }

The itkWeightedCovarianceCalculator class looks like it has this bug  
as well but in two places in similar loops.



Secondly, the method CannyEdgeDetectionImageFilter::SetMaximumError   
has a small mistake in it. It looks like it should be checking to see  
if the value v is different the the current value before setting it.

if (m_Variance[i] != v)

should be:

if (m_MaximumError[i] != v)

Thank,
Brad


========================================================
Bradley Lowekamp
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080618/7ddfd578/attachment.htm>


More information about the Insight-users mailing list