[Insight-users] Histogram statistics

Martin Kavec kavec at messi.uku.fi
Tue Oct 25 16:23:33 EDT 2005


Hi Luis,

and thanks for your reply.

On Tuesday 25 October 2005 04:13, Luis Ibanez wrote:
> Hi Martin,
>
> Just double checking:
>
> What is slow is:
>
>      A) The comptation of the Histogram ?
>      B) the computation of the Quantile ?
>
> I would expect that most of the time is spent
> computing the actual histogram.
>
> Could you please put a RealTimeClock in between
> both operations and let us know how much time
> is spent in both operations.

The image is pretty large, 256x256x120. I am re-implementing a filter, which 
needs the quantiles of histogram as an input and that implementation ( made 
in C ) gives me the values instantly. I mean, fraction of a second. I know 
that it is difficult to compare.

You guess right, the computation of the histogram 

histogramGenerator->Compute();

takes the most time, 12 seconds, and both 2% quantiles take 60 micro seconds 
to compute. It is fare to say parameters of my PC: 2GHz Centrino, 1GB RAM. 
The measures were taken on ITK and testing code compiled both without any 
compiler optimization flags.

I used cachegrind to profile the code and I found that it is 
itk::Statistics::Histogram::GetIndex and callees below ( especially the 
std::vector::operator[](unsigned) ), who take the most of the execution time, 
82%.

I have been able to cut the execution time by 40%, but still the histogram 
calculation take almost as long as pretty hefty neighborhood calculations. So 
it would be great, if I could run faster.

>
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1RealTimeClock.html
>
> Also, please let us know of the size of your
> image and its pixel type.
>
>
>
>    Thanks
>
>
>      Luis

Thanks a lot.

Martin

>
>
> ----------------
>
> Martin Kavec wrote:
> > Hello everybody,
> >
> > I am trying to calculate some statistics out of the image histogram, but
> > the execution is pretty slow. Here is what I do:
> >
> > typedef itk::Statistics::ScalarImageToHistogramGenerator< InputImageType
> > > HistogramGeneratorType;
> >    typename HistogramGeneratorType::Pointer histogramGenerator =
> > HistogramGeneratorType::New();
> >
> >    histogramGenerator->SetInput( input );
> >    histogramGenerator->SetNumberOfBins( 1000 );
> >    histogramGenerator->SetMarginalScale( 10.0 );
> >    histogramGenerator->Compute();
> >
> >    typedef typename HistogramGeneratorType::HistogramType  HistogramType;
> >    const HistogramType *histogram = histogramGenerator->GetOutput();
> >
> >    m_BrightnessThreshold = histogram->Quantile( 0, 0.98 );
> >
> >
> > Is there any way to speed this up, or any other way to calculate the
> > histogram quantile?
> >
> > Thans,
> >
> > Martin
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list