[Insight-users] Histogram modification - troubles with SetFrequency

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 2 15:52:25 EST 2009


Hi Sacrif,

In the old statistics framework,
the FrequencyType of the Histogram is defined as:

                   typedef float FrequencyType;

in the file

  Insight/Code/Numerics/Statistics/itkDenseFrequencyContainer.h



When you say about the expression:


>  histogram->SetFrequency(bin, pow(histogram->GetFrequency(bin,0),2)); //
> pow(x,2)


that:

                "It doesn't work"...


do you mean that:

A) It doesn't compile ?

B) It seg. faults at run time ?

C) It throws an exception at run time ?

D) It doesn't produce any errors, but the resulting
    numerical value is not the expected one  ?


  Please be more specific,


       Thanks


              Luis

----------

BTW: Please note that the Statistics Framework was fully
refactored and that the new version is under:

    Insight/Code/Review/Statistics

we strongly encourage you to adopt this new version.

In order to use it, you just need to reconfigure ITK with CMake
and turn ON the following two CMake variables:

          ITK_USE_REVIEW
          ITK_USE_REVIEW_STATISTICS





--------------------------------------------------------------------------------------------------------------
On Wed, Dec 2, 2009 at 3:34 PM, sacrif <markus_m at gmx.net> wrote:
>
> 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.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list