1.2.9. Histogram Data

A histogram is often useful to visualize the distribution of values in a volume data set.

The getHistogram() method in SoVolumeData SoVolumeData SoVolumeData returns a histogram for the volume as an array of integers and a count. The count is the number of bins in the histogram. Depending on the number of bins and the range of values the histogram represents, each bin may represent a single voxel value or a range of voxel values. When a volume is converted to LDM format, VolumeViz (by default) builds a histogram and stores the histogram in the LDM file header. When an application calls the getHistogram() method, VolumeViz asks the volume reader for the histogram. If the volume is in LDM format, the reader will normally have a histogram available (read from the file header) and the getHistogram() method returns quickly. Custom volume readers that have a pre-computed histogram can also satisfy this request quickly. For most volume data formats (and for in-memory volumes) the histogram must be computed by the getHistogram() method, which can take a lot of time for a large volume. In this case, if the application may need to re-use the histogram in subsequent runs, the application should store the histogram.

Internally VolumeViz uses the class SoVolumeHistogram SoVolumeHistogram SoVolumeHistogram to build and manage a histogram. Applications can also use this class directly to build and query a histogram. An instance of SoVolumeHistogram SoVolumeHistogram SoVolumeHistogram is not directly associated with an SoVolumeData SoVolumeData SoVolumeData node. Instead the SoVolumeHistogram SoVolumeHistogram SoVolumeHistogram builds a histogram from one or more buffers of data passed to the addValues() method. This allows the application to build a histogram for a region of a volume or even a single slice. The data access API (discussed in Section 1.10, “Data Access and Computing” can be used to get the data from the volume.

The current implementation of SoVolumeHistogram SoVolumeHistogram SoVolumeHistogram has some limitations, in particular it is not possible to specify the number of bins in the histogram or the value range for integer data types. Applications using integer data types larger than one byte may wish to implement their own histogram computation to avoid these limitations.

VolumeViz does not provide a class to plot the histogram. This can be done using standard Open Inventor primitives. Plotting a histogram can also be done more conveniently using the graphing classes in the MeshViz extension, for example PoRegularMesh1D PoRegularMesh1D PoRegularMesh1D , PoLinearBar PoLinearBar PoLinearBar , PoCurveFilling PoCurveFilling PoCurveFilling and PoLinearAxis PoLinearAxis PoLinearAxis .