[Insight-users] Maximum bound not properly handled in itkHistogram

Koen Van Leemput koen . vanleemput at hus . fi
Wed, 14 Aug 2002 10:45:36 +0300


When I try to construct a histogram from an image with minimum and maximu=
m=20
voxel value "minValue" and "maxValue", respectively, I run into trouble w=
hen=20
trying to bin a voxel with value "maxValue".=20

Here is what happens:

itk::Histogram::Pointer    histogram =3D itk::Histogram::New();
histogram->Initialize( numberOfBins, minValue, maxValue );
histogram->IncreaseFrequency( maxValue, 1 );  // Error!

The problem lies in itk::Histogram::GetIndex(const MeasurementVectorType=20
&measurement), where "maxValue" is considered out of bounds, whereas I wo=
uld=20
have wanted it to end up in the last bin.=20

Of course, I could artificially make the width of the last bin a bit bigg=
er,=20
so as to catch the "maxValue" properly:

histogram->SetBinMax( 0, numberOfBins-1, maxValue + (maxValue -=20
minValue)/numberOfBins );

However, I think it would be more logical if the "maxValue case" would be=
=20
handled automatically in the implementation of itkHistogram...

Cheers,

Koen


--=20
*************************************************************************=
****=20
Koen Van Leemput, Ph.D.                email : koen.vanleemput@hus.fi=20
Department of Radiology                  phone: +358 9 471 71331       =20
Helsinki University Central Hospital   mobile: +358 9 471 62300       =20
P.O. Box 340                                  fax:      +358 9 471 71342 =
      =20
FIN-00029 HUS                                                            =
              =20
FINLAND                                                                  =
                 =20
*************************************************************************=
****=20