setHistAttr
Top  Previous  Next

setHistAttr ( integer Bins [, floating Min =minpix, floating Max =maxpix, integer Sampling=1,
integer Ignore =0, integer Calibrate =0 ] )  

Use this function to set environmental parameters for the histogram. These parameters affect all the functions based on the histogram processing. Equivalent to selecting Preferences/Histograms in the Edit menu and changing the settings in the Histogram Tool.
.
Parameters
 
Bins  
 
A positive integer specifying the 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.  
 
Min, Max  
 
Optional floating arguments specifying the minimum and maximum pixel values used to compute the histogram. If these parameters are omitted, the histogram limits will be set to the minimum and maximum permitted pixel values for the given image type in order to cover the full intensity range of the image.  
 
Sampling  
 
An optional integer between 1 and 16 specifying the step, which is used to collect the pixels 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 image processing functions based on the histogram calculations (most of the automatic segmentation methods), but sacrifices some accuracy.  
Default value: 1  
 
Ignore  
 
An optional enumerated integer specifying whether the black and/or white pixels should be ignored in histogram measurements. Ignoring black and white pixels can significantly improve an outcome of the histogram-based functions (such as automatic segmentation), if an image has an extensive contrast. Must be one of the following values:  
 
IGN_NONE=0 – all pixel values are taken into account.  
IGN_BLACK=1 – ignore black pixels (minimum permitted value for a given image type) when collecting the histogram data.  
IGN_WHITE=2 – ignore white pixels (maximum permitted value for a given image type) when collecting the histogram data.  
IGN_BW=3 – ignore black and white pixels when collecting the histogram data.  
Default value: IGN_NONE  
 
Calibrate  
 
An optional enumerated integer specifying whether the histogram data must be collected according to the current spatial or/and intensity calibration scales. Must be one of the following values:  
 
CAL_NONE=0 – measures histogram spatial and intensity values in uncalibrated form. The histogram bins will contain a number of pixels for a given intensity range and intensity data and statistics will be reported in actual pixel's values.  
CAL_SPACE=1 – measures histogram spatial values in calibrated form. The histogram bins will contain the spatial area of each intensity range in the image.  
CAL_INT=2 – measures histogram intensity values in calibrated form. X-axis data and statistics will be reported in calibrated intensity values.  
CAL_BOTH=3 – measures both spatial (Y-axis) and intensity (X-axis) values in calibrated form.  
Default value: CAL_NONE  
 
 
Error flags
 
ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  

Example
 
This set of statements sets the histogram parameters and displays the histogram of a sample image:  
 
setCurDir ("samples")  
loadIm (1,"sample8.iwd")  
bins=128  
min=10  
max=255  
sampling=4  
setHistAttr (bins,min,max,sampling,IGN_WHITE)  
showHistogram (TRUE)  
 
Remark
 
The Calibrate parameter will also affect line profile measurements. If the spatial calibration is selected, the distance along the profile line will be reported in calibrated units. If the intensity calibration is selected, the profile data will be reported in calibrated intensity values.