measHistogram
Top  Previous  Next

measHistogram ( integer Input [, integer Channel =CH_LUM, integer Mode =HS_ARRAY,
string File =0 ] )  

Use this function to measure the histogram of a current image or selection. The data are collected in a global measurement parameter Histogram accessible via
getParamValue.

Parameters
 
Input  
 
An integer between 1 and 116 specifying the frame number of the image for which the histogram data are to be obtained. Values in the range of 100-116 correspond to hidden frames.  
.  
Channel  
 
An optional enumerated integer specifying a color channel for which the histogram data are to be obtained. This parameter is disregarded for grayscale images. Must be one of the following values:  
 
CH_LUM=0 – collects the histogram of the luminance of the image using the formula: Lum=0.3R+0.59G+0.11B  
CH_RED=1 – collects the histogram of the red component of the image.  
CH_GREEN=2 – collects the histogram of the green component of the image.  
CH_BLUE=3 – collects the histogram of the blue component of the image.  
CH_HUE=4 – collects the histogram of the hue component of the image using the HLS color model.  
CH_LIGHT=5 – collects the histogram of the luminance component of the image using the HLS color model.  
CH_SAT=6 – collects the histogram of the saturation component of the image using the HLS color model.  
CH_IPHASE=7 – collects the histogram of the I-Phase component of the image using the YIQ color model.  
CH_QUADR=8 – collects the histogram of the Quadrature component of the image using the YIQ color model.  
Default value: 0  
 
Mode  
An optional enumerated integer specifying the mode for the histogram measurements. Must be one of the following values:  
 
HS_ARRAY=0- collects an array of frequencies (number of pixels at each intensity range).  
HS_STAT=1 – collects statistical data associated with the histogram. The statistics is written to the Histogram parameter-array, as follows: Histogram(0) – Mean value, Histogram(1) – Standard deviation, Histogram(2) – Sum, Histogram(3) – Minimum, Histogram(4) – Maximum, Histogram (5) – Median, Histogram(6)–Skewness, Histogram(7) – Kurtosis.  
Default value: HS_ARRAY  
 
File  
 
An optional string specifying the name of the ImageWarp data file for saving the histogram data. If this parameter is zero or omitted, the data will not be written to a file.  
Dafault value: 0  
 
Error flags

ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
ERR_BADFILE  
 
The flag set if the file could not be open.  
 
ERR_NOSPACE  
 
The flag set if there is not enough space to write the file.  

Example

This set of statements measures the histogram of a selected area in a sample image and prints the statistics:  
 
setCurDir ("samples")  
loadIm (1,"sample8.iwd")  
setSelect (1, SH_RECT, SEL_NEW, 21, 26, 367, 284)  
measHistogram (1, CH_LUM, HS_STAT)  
 
Remark
 
Before applying this function, make sure to set the proper histogram environment variables by calling setHistAttr. If you want to get the histogram data from a specific region of an image, use setSelect.to define the region of interest.