[Insight-users] Histogram modification - troubles with SetFrequency

sacrif markus_m at gmx.net
Wed Dec 2 15:34:17 EST 2009


Hello, 

I am new to ITK and have troubles with the histogram->SetFrequency() 
method.
What I did yet was to read in a 3d Analyse image (.hdr and .img format)
using the filereader
and the AnlayseImageIO class. Then I used the
"itkScalarImageToHistogramGenerator.h" class to create a histogram out of
the image I read in. So far everything worked well. However my next step is
to modify the histogram. I want to exponentiate the frequency value of every
bin by a certain number.  I tried to do that with the following code. 

//-------------------------------------------
typedef signed short PixelType;
static const unsigned int Dimension = 3;
typedef itk::Image<PixelType, Dimension> ImageType;
typedef itk::Statistics::ScalarImageToHistogramGenerator< ImageType >
HistogramGeneratorType;               
typedef HistogramGeneratorType::HistogramType  HistogramType;
  ...
  const HistogramType * histogram = histogramGenerator->GetOutput();
  const unsigned int histogramSize = histogram->Size();

  unsigned int bin;
  for( bin=0; bin < histogramSize; bin++ )
    {
	histogram->SetFrequency(bin, pow(histogram->GetFrequency(bin,0),2)); //
pow(x,2) just exponentitates x with 2.
    }
//-------------------------------------------
    
Unfortunately this does not work - obviously "unsigned int" is not the right
type to asign. 
I also tried to define:
	HistogramType::IndexType index;
	index[0] = 1000; // just as an example

and put "index" at the place of "bin"( histogram->SetFrequency(index,
pow(histogram->GetFrequency(bin,0),2));), but it did not work.
Could you please tell me what kind of arguments SetFrequency needs, or
whether there is a better way to modify the histogram.
(histogram->GetFrequency(bin, 0) works without any problems by the way)

Kind Regards 
Mark
-- 
View this message in context: http://old.nabble.com/Histogram-modification---troubles-with-SetFrequency-tp26615939p26615939.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list