[Insight-users] problem in itkimagegaussianmodel estimator

Ting Chen chenting@graphics.cis.upenn.edu
Tue, 7 Jan 2003 12:46:03 -0500


from line 292 to 300

      unsigned int vdimension = VectorDimension - 1;
        for(unsigned int band_x = 0; band_x < (vdimension - 1); band_x++)
          {
          for(unsigned int band_y=band_x+1; band_y < vdimension; band_y++)
            {
            m_Covariance[classIndex][band_x][band_y]
              = m_Covariance[classIndex][band_y][band_x];
            }// end band_y loop
          }// end band_x loop

it works well to calculate covariance matrice if the VectorDimension > 1,
however, for single channel images where VectorDimension equal to 1,
vdimension = 0. the band_x loop will have problem since vdimension-1 = -1,
but band_x and vdimension are unisgned int variables.


should it be changed to

      unsigned int vdimension = VectorDimension - 1;
      if (vdimension > 0)
        {
        for(unsigned int band_x = 0; band_x < (vdimension - 1); band_x++)
          {
          for(unsigned int band_y=band_x+1; band_y < vdimension; band_y++)
            {
            m_Covariance[classIndex][band_x][band_y]
              = m_Covariance[classIndex][band_y][band_x];
            }// end band_y loop
          }// end band_x loop
        }// end if loop

to make sure it works for single channel image?


thanks

ting