[vtkusers] A simple and efficient histogram class?

Andras Lasso lasso at queensu.ca
Wed Sep 20 11:43:46 EDT 2017


You can find higher-level widgets like this in CTK. For example, http://www.commontk.org/index.php/Documentation/ctkTransferFunctionWidget.

Andras

From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of David Gobbi
Sent: Wednesday, September 20, 2017 11:15 AM
To: Miguel Nunes <m.nunes at fratoria.com>
Cc: VTK Users <vtkusers at vtk.org>
Subject: Re: [vtkusers] A simple and efficient histogram class?

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<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.kitware.com%2Fvtk%2Fvtk%2Fblob%2Fmaster%2FImaging%2FCore%2FTesting%2FCxx%2FImageHistogram.cxx&data=02%7C01%7Classo%40queensu.ca%7C43231217f85e4232906508d5003a63e4%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636415173137430197&sdata=bLPacE94PkaGB7%2B%2Bhx8MZnEuBCE9OizpRTN7zzN9qig%3D&reserved=0>

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<mailto: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/07c62956/attachment.html>


More information about the vtkusers mailing list