Leaper Vision Toolkit
中文 / English 2.x
Public Member Functions
ILHistogram Interface Reference

This interface provide functionalities of histogram calculation out of image. More...

Inheritance diagram for ILHistogram:
ILObject LHistogram

Public Member Functions

void Build (ILImage *img, ILRegion *region, int binCount, int lowerBound, int upperBound)
 
void BuildFromDataVec (LArray< double > dataVec, int binCount, double lowerBound, double upperBound)
 
void Draw (HDC hdc, LPVChartDrawFlags drawFlags, int xGridStep, int yGridStep)
 
double Item (int index)
 
void MeanStdDev (double *meanValue, double *stdDevValue)
 
void MinMax (int *minIdx, double *minValue, int *maxIdx, double *maxValue)
 
- Public Member Functions inherited from ILObject
ILObjectCopy ()
 
LPVErrorCode Load (LString filename)
 
void Reset ()
 
LPVErrorCode Save (LString filename)
 
BOOL Valid ()
 

Detailed Description

This interface provide functionalities of histogram calculation out of image.

Histogram collect count of data in provided image into a set of predefined bins. It is useful in a vision system for analysis and observe the frequency distributions of pixel intensity values, and later do detection or inspection based on it.

To use this interface, you should create a LHistogram object.

Example Code

Member Function Documentation

◆ Build()

void Build ( ILImage img,
ILRegion region,
int  binCount,
int  lowerBound,
int  upperBound 
)

Build the histogram with the given image and region.

Parameters
[in]img The input image.
[in]regionInput region. It's optional, could be null.
[in]binCountThe number of divisions in the histogram. It's recommended to be a factor of the total data range size, say 256 for a grayscale image.
[in]lowerBoundThe lower bound of data, usually it's 0 for a 8bit grayscale image.
[in]upperBoundThe upper bound of data, usually it's 255 for a 8bit grayscale image.
See also
BuildFromDataVec()

◆ BuildFromDataVec()

void BuildFromDataVec ( LArray< double >  dataVec,
int  binCount,
double  lowerBound,
double  upperBound 
)

Build the histogram with the given data vector.

Parameters
[in]dataVecThe input data vector, it's a collection of double values.
[in]binCountThe number of divisions in the histogram.
[in]lowerBoundThe lower bound of data. By default, both the lower and upper bound is set to 0, means we'll use the minimum and maximum value of the inputs as the bounds.
[in]upperBoundThe upper bound of data.
See also
Build()

◆ Draw()

void Draw ( HDC  hdc,
LPVChartDrawFlags  drawFlags,
int  xGridStep,
int  yGridStep 
)

Draw the histogram as a data chart onto provide device context, using the index as x axis and the value as y axis.

Parameters
[in]hdcHandle to the device context of the destination window or bitmap.
[in]drawFlagsFlags to control which part of a data chart should be drawn, see LPVChartDrawFlags for usage.
[in]xGridStepSpecify the step of label on x axis, 0 means we'll determine it on the fly according to the score data.
[in]yGridStepSpecify the step of label on y axis, 0 means we'll determine it on the fly according to the score data. This function is currently not available on Linux / MacOS platform.

◆ Item()

double Item ( int  index)

Get value of a specified bin. It represents the count of data in that bin.

Parameters
[in]indexThe index of the bin.
Return values
valueReturn the value of the bin.

◆ MeanStdDev()

void MeanStdDev ( double *  meanValue,
double *  stdDevValue 
)

Calculate the mean and standard deviation of the histogram.

Parameters
[out]meanValueReturn the mean value.
[out]stdDevValueReturn the standard deviation value.

◆ MinMax()

void MinMax ( int *  minIdx,
double *  minValue,
int *  maxIdx,
double *  maxValue 
)

Find the bin of minimum or maximum value, report the value and bin index. If there's more than one bin with the same value, report the first one.

Parameters
[out]minIdxReturn the index of the bin of minimum value.
[out]minValueReturn the minimum value.
[out]maxIdxReturn the index of the bin of maximum value.
[out]maxValueReturn the maximum value。