2.6.2.1 imgHistogram

Menu Information

Analysis: Histogram

Brief Information

Generate image histogram

Command Line Usage

1. imgHistogram c:=rgb;
2. imgHistogram img:=Mat(1) c:=red plot:=0;
3. imgHistogram img:=[Mbook1]Msheet1!Mat(1);

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix img

Input

Image

<active>

This variable specifies the source image to be manipulated. The default input is the active image.

Channel c

Input

int

rgb

This variable specifies the channel for which a histogram is to be calculated.
Option list

  • M:Master
    Master channel
  • R:Red
    Red channel only
  • G:Green
    Green channel only
  • B:Blue
    Blue channel only
  • R:RGB
  • RGB channels separately
Output rd

Output

ReportData

<new>

This variable specifies the output report.

Plot plot

Input

int

1

This variable specifies whether to plot the histogram curves.

Description

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.


Examples

  • Code Sample
// 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

Related X-Functions

imgHistcontrast, imgHisteq