Histogram
Submitted by dave on February 19, 2008  17:25
To create a DICOM Image Histogram Module, users of DicomObjects can use the DicomImage.Histogram method, which returns an array containing the distribution of the raw pixel values.
[Declaration]
DicomImage.Histogram(Min, Max, BinSize)
[Parameters]
 Min as Long Integer  The lowest pixel value to be included.
 Max as Long Integer  The highest pixel value to be included.
 BinSize as Long Integer  The number of adjacent pixel values to be grouped into each Bin
[Return Value]
A variant array of Long Integers containing the distribution of raw pixel values, the index of the array is 1based.
[Explanations]

How to decide Min and Max
 DicomImage.MinimumPixelValue and DicomImage.MaximumPixelValue methods could be used to decide the minimum and maximum values of the pixel data. This approach is not very efficient as they are big operations in DicomObjects.
 A better way of deciding the Min and Max is to use "Bits Stored" (0028, 0101) and "Pixel Representation" (0028, 0103): N = Bits Stored (0028, 0101); Pixel Representation (0028, 0103) indicates whether the pixel data value is signed or unsigned. If signed then the pixel data range is ( 2^(N1)) to (2^(N1)). And if unsigned, the pixel data range is 0 to (2^N – 1).

What is BinSize
 The BinSize is the value people choose to define how many pixel values get put into each returned bin, so for instance if you have Min=10 and Binsize=5, then the bins are: 1014, 1519, 2024, Etc.

What is in the returned array
 The returned variant array of Long Integers contains the distribution of raw pixel values. For example we have a pixel data at range 10  24, the BinSize is set to 5 so that we have 3 bins: 1014, 1519, 2024. A returned array of [30,40,50] means 30 pixel data are within the value range (1014), 40 pixel data within the value range (1519) and 50 pixel data within the value range (2024). You can then feed the info into a chart control to get the Histogram graph.