Top  Previous  Next


Returns the histogram of the current image frame over a selected ROI .


Value=objActiveDcam.GetHistogram(Component [,Bins, Step ])

HRESULT GetHistogram( VARIANT* pHistogram, short Component, long Bins=256, short Step=1 );

Data Types

Channel : Integer
Bins : Long
: Integer
Return value: Variant (Array)


Component [in]  
Enumerated integer specifying the color component for which the histogram data are obtained. This parameter is disregarded for grayscale images. Must be one of the following values:  
0 - collects the histogram of the luminance of the image  
1 - collects the histogram of the red component of the image  
2 - collects the histogram of the green component of the image  
3 - collects the histogram of the blue component of the image  
Bins [in]  
Number of intervals used for histogram collection. It is recommended to set this parameter to a number of possible intensity levels in the image or to an integer fraction of that value, otherwise some precision will be lost due to averaging that occurs within the consolidated bins. A typical number of histogram bins for 8-bit and 16=bit images will be 256.  

Step [in]  
An optional integer between 1 and 16 specifying the sampling step, which is used to collect pixel values for the histogram calculations. If this number is 1, every pixel is taking into consideration. If the number is 2, every second pixel in a row will be skipped, as well as every second row in the image, etc. Increasing the sampling step raises the speed of the histogram calculations, but sacrifices some accuracy.  
pHistogram [out,retval]  
Pointer to the SAFEARRAY containing the histogram values.  
Return Values



This VB example retrieves the histogram of the red component per each frame acquired:

Private Sub

ActiveDcam1.SetROI 100,100,500, 400 

HistArray=ActiveDcam1.GetHistogram (1, 256)
End Sub


The histogram is calculated over the rectangular region of interest defined by SetROI. The luminance thresholds of the current ROI are disregarded. If the ROI is not set, the whole image frame will be used.