[vtkusers] A simple and efficient histogram class?

David Gobbi david.gobbi at gmail.com
Wed Sep 20 11:14:47 EDT 2017


Hi Miguel,

I think you listed all the histogram classes.  The simplest is
vtkImageHistogram, e.g.
https://gitlab.kitware.com/vtk/vtk/blob/master/Imaging/Core/Testing/Cxx/
ImageHistogram.cxx

Rather than producing a plot, per se, it produces the histogram as an
image.  It's basic interface is:

SetNumberOfBins(15)
SetBinSpacing(1.0)
SetBinOrigin(0.0)

So you would need to compute the "BinSpacing" from your desired range.  The
"BinOrigin" is simply the lower end of the range.

As well as producing an image of the histogram, it has a GetHistogram()
method for getting the histogram as an array.

 - David


On Wed, Sep 20, 2017 at 8:09 AM, Miguel Nunes <m.nunes at fratoria.com> wrote:

> Hello,
> I would like to ask this list about histograms in VTK c++. I have been a
> vtk
> user for several years, but never had the need to use histograms through
> vtk
> as I was using pure c++ and openGL.
> Now, I would like to simply plot a basic histogram of a float 3d image. I
> have taken a look at the examples provided but I find myself quite
> confused.
>  Honestly, for an advanced visualization toolkit I am quite surprised to
> find
> it so complicated. There are classes such as vtkPlot that allow bars, then
> there is vtkBarChartActor, vtkImageAccumulate, vtkXYPlotActor,
> vtkImageHistogramStatistics and vtkImageHistogram.
>
> It all needs to be remixed, connected and many properties have to be set
> manually.
>
> Maybe I am missing a class (or the point), but in general terms I would
> like
> to easily plot and render a simple histogram, like:
>
> myHistogram->setData( vtkImagaData *)
> myHistogram->setXRange(range[2]) // clips values under and above the
> range specified
> myHistogram->setNumberOfBins(15) // calculates the bin width and each
> bins' Y
> myHistogram->update()            //generate the whole thing
> renderer->getActor()->setData(myHistogram)
>
> ...and then its done.
>
> Any chance this actually exist? Thank you very much!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170920/d861bffc/attachment.html>


More information about the vtkusers mailing list