[Insight-users] Retrieving values from an histogram...

Luis Ibanez luis.ibanez at kitware.com
Wed, 11 Feb 2004 16:36:00 -0500


Hi Jean-Philippe,

I'm afraid you are expecting too
much from the Histogram.   :-)

When the histogram count entries in
a bin it summarizes the information
as if all the entries have the value
corresponding to the middle of the bin.

That is,
If the bin has min and max values:

             binmin = 1.5
             binmax = 2.5

and you feed the histogram with values

        1.7, 1.9, 2.13, 2.45

All these four values will be counted
in this bin. The counter will say that
you got 4 hits in this bin, and if you
ask the value of the bin you will get:

                 2.0

which is the middle value between the
min and the max values of the bin in
this case.

The information about the actual distribution
of values that contributed to this bin is
irreparably lost (as far as the histogram
is concerned).

If you actually need the original values,
you will need a second pass through the
image collecting all the values between
binmin and binmax.


Regards,


   Luis


--------------------------
Jean-Philippe Guyon wrote:

> Hello,
>  
> I am having a hard time figuring out how to retrieve values from an 
> histogram that I generate using the 
> itk::ListSampleToHistogramGenerator.The measurement vector from a 
> bin, which I obtain using the GetMeasurementVector() function, always 
> contains a single element. My understanding is that a bin with a 
> frequency of 10 should have a measurement vector that contains 10 
> values. Is that correct ???
> If that is correct, here is the code I am using to view the content of 
> the generated histogram:
> 
> --------------------------------------
> unsigned int size = this->m_Histogram->Size();
> 
> for( unsigned int x=0; x<size; x++ )
>   {
>   std::cout<<"Bin: "<<x<<std::endl;
>   std::cout<<"Bin Frequency: 
> "<<this->m_Histogram->GetFrequency(x,0)<<std::endl;
>   std::cout<<"Measurement: 
> "<<this->m_Histogram->GetMeasurementVector(x)<<std::endl;
>   }
> --------------------------------------
> 
> Am I missing anything ??? Is there any example that illustrates how to 
> retrieve values from an histogram. I could not find a specific paragraph 
> about this topic in the ITK software guide.
>  
> Thanks,
>  
> Jean-Philippe