[Insight-users] need help image histogram

hossein nazem hn_6112 at yahoo.com
Wed Sep 10 02:58:28 EDT 2008

Dear Luis
Thank you for your consideration. It seems that a mapping take place somewhere and convert data from uint16 to unit8.
These are my parameters:
  histogramGenerator->SetNumberOfBins( 4096 );
  histogramGenerator->SetMarginalScale( 1 );
  histogramGenerator->SetHistogramMin(  -0.5 );
  histogramGenerator->SetHistogramMax( 4096 );
I expect that I have frequency of nearly 1000 around bin no 1000 but its 0 and I expect that some of frequency match the total sum of pixels but its nearly half of the total sum.
I need the real histogram (0-4096).
And here is how I check the result for each bin (actually I use the examples I mentioned before):
std::cout << histogram->GetFrequency( bin, 0 ) << std::endl;
And the total number of pixels must be equal to:
s=s+histogram->GetFrequency( bin, 0 );
Yours truly,


--- On Tue, 9/9/08, Luis Ibanez <luis.ibanez at kitware.com> wrote:

From: Luis Ibanez <luis.ibanez at kitware.com>
Subject: Re: [Insight-users] need help image histogram
To: hn_6112 at yahoo.com
Cc: insight-users at itk.org
Date: Tuesday, September 9, 2008, 9:22 PM

Hi Hossein,

What values did you set up for the Max and Min of the Histogram ?

   min.Fill(   -0.5 );  ??
   max.Fill(  255.5 );  ??

   generator->SetHistogramMin( min );
   generator->SetHistogramMax( max );

If the total number of entries in the Histogram doesn't match the
number of pixels in the image, then it is likely that your Min and
Max setting in the histogram calculator are defining an intensity
range smaller than the actual dynamic range of your DICOM image.

Please let us know,



hossein nazem wrote:
> Hi,
> I’m trying to extract the histogram of a dicom image. The result is 
> different to what I achieve from MATLAB. There is something wrong in itk 
> because total pixels are fix and 512*512=262144 but in my code it’s 
> variable when I change the bins,  and the shape of histogram is 
> different comparing with MATLAB output. I work on a 512*512 dicom uint12 
> image. I tried the Examples/Statistics/ImageHistogram1.cxx & 
> Examples/Statistics/ImageHistogram2.cxx.
> Yours truly,
> Hossein
> ------------------------------------------------------------------------
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080909/bfa52900/attachment-0001.htm>

More information about the Insight-users mailing list