LightMeterRectangle Method

NI Vision for Visual Basic

LightMeterRectangle Method

Syntax

CWMachineVision.LightMeterRectangle SourceImage, RotatedRectangle, LightMeterRectangleReport [, ShowSearchArea = True] [, CoordinateTransformation]

Return Type

Long

On success, this method returns 0. On failure, this function returns a negative number.

Purpose

Calculates statistics about the pixel intensities inside a rectangular region of an image.

Remarks

Use this method with U8, I16, and SGL images.

Parameters

SourceImage As CWIMAQImage

The input image.

RotatedRectangle As CWIMAQRotatedRectangle

The region of the image in which to measure the intensities.

LightMeterRectangleReport As CWMVLightMeterRectangleReport

On return, a report containing information about the intensities in the selected region.

ShowSearchArea As Boolean

[Optional] If True, the search area is overlaid on the image.

This parameter has a default value of True.

CoordinateTransformation As Variant

[Optional] A CWMVCoordinateTransformation object. If supplied, the input search area is transformed using this parameter.

Example

Private Sub Run_Click()
    'Inputs to LightMeterRectangle
    Dim SearchArea As New CWIMAQRotatedRectangle
    Dim Transformation As New CWMVCoordinateTransformation
    
    'Outputs of LightMeterRectangle
    Dim Report As New CWMVLightMeterRectangleReport
    
    'Get the rotated rectangle from the viewer. If there is no region selected, the entire image
    'will be processed
    CWMachineVision1.GetSelectedRotatedRectFromViewer CWIMAQViewer1, SearchArea, False
    
    'Measure the intensity inside the search region
    CWMachineVision1.LightMeterRectangle CWIMAQViewer1.Image, SearchArea, Report, , Transformation

    'Display the mean intensity in a text box
    Text1.Text = Report.MeanIntensity
End Sub

Light Meter Example

See Also

CWIMAQVision.Histogram2

GetSelectedRectangleFromViewer