Equalize2 Method

NI Vision for Visual Basic

Equalize2 Method

Syntax

CWIMAQVision.Equalize2 SourceImage, DestImage [, HistogramReport] [, MinValue = 0] [, MaxValue] [, MaskImage]

Return Type

Long

The image to process.

Purpose

Calculates the histogram of an image and redistributes pixel values across the appropriate range to maintain the same pixel value distribution. Pixels whose values are the same before the redistribution also have common pixel values after the redistribution.

Remarks

Use this method with U8, I16, and SGL images. MaskImage must be a U8 image.

If you do not supply the HistogramReport parameter then the method computes the histogram from the source image to equalize the image.

Parameters

SourceImage As CWIMAQImage

The source image.

DestImage As CWIMAQImage

The resulting image.

HistogramReport As Variant

[Optional] If supplied, the histogram of the source image that is supplied as an output of the CWIMAQVision.Histogram function. It is necessary to input the same image to both CWIMAQVision.Histogram and this function.

MinValue As Variant

[Optional] The minimum value of the range to which the method equalizes the image.

This parameter has a default value of 0.

MaxValue As Variant

[Optional] The maximum value of the range to which the method equalizes the image.

MaskImage As Variant

[Optional] A CWIMAQImage object that specifies the region in which the method performs the equalization. The method processes only those pixels in the image whose corresponding pixels in the mask are non-zero. Do not set this parameter if you want to calculate a histogram equalization on the entire image.

Example

Private Sub Run_Click()
    Dim i As New CWIMAQImage
    Dim HistogramReport As New CWIMAQHistogramReport
    Dim MaskImage As New CWIMAQImage
    Dim HistogramOptions As New CWIMAQHistogramOptions
    
    ' Equalize a portion of the image in Viewer1
    ' defined by the regions on Viewer1 and
    ' store the result in i.
    CWIMAQVision1.RegionsToMask MaskImage, CWIMAQViewer1.Regions
    
    CWIMAQVision1.Equalize2 CWIMAQViewer1.Image, i, , , , MaskImage
    
    ' Calculate the histogram of the image in Viewer1 and then use
    ' this histogram to perform the equalization.
    ' Do the equalization inplace. Store the results in
    ' the image in Viewer1.
    HistogramOptions.NumberOfClasses = 128
    CWIMAQVision1.Histogram2 CWIMAQViewer1.Image, HistogramReport, HistogramOptions

    CWIMAQVision1.Equalize2 CWIMAQViewer1.Image, CWIMAQViewer1.Image, HistogramReport
End Sub

See Also

Histogram2

Threshold

CWIMAQHistogramReport