Analysis: Histogram
Generate image histogram
1. imgHistogram c:=rgb; 2. imgHistogram img:=Mat(1) c:=red plot:=0; 3. imgHistogram img:=[Mbook1]Msheet1!Mat(1);
Please refer to the page for additional option switches when accessing the x-function from script
Input
Image
This variable specifies the source image to be manipulated. The default input is the active image.
int
This variable specifies the channel for which a histogram is to be calculated. Option list
Output
ReportData
This variable specifies the output report.
This variable specifies whether to plot the histogram curves.
A histogram for a color channel is a function of levels. For each level, it shows how many pixels in the channel have that level.
The imgHistogram function calculates the histogram for any specified channel in the input image. You can use it to analyze the distribution of colors in the image.
// Histogram calculation //Create a new folder in the Project Explorer pe_mkdir HistogramContrast path:=aa$; pe_cd aa$; //Create a hidden workbook for the histogram results newbook sheet:=2 name:=HistogramResult Hidden:=1 result:=ResultBK$; //Create a matrix and import an image into it window -t m; fname$ = System.path.program$ +"samples\Image Processing and Analysis\cell.jpg"; impimage; window -r %h Original; imgc2gray; //Duplicate the image and use histogram constrast to modify it window -d; window -r %h Modified; imgHistcontrast a:=30; //Calculate histogram imgHistogram img:=Original c:=master rd:=[ResultBK$]1; page.label$ = Histogram of Original; page.title=1; imgHistogram img:=Modified c:=master rd:=[ResultBK$]2; page.label$ = Histogram of Modified; page.title=1; window -s T; //Tile the windows horizontally
imgHistcontrast, imgHisteq