Chapter 3
Grayscale and Color Measurements
IMAQ Vision for LabWindows/CVI User Manual
3-6
ni.com
You can also use
imaqSelectPoint()
,
imaqSelectLine()
,
imaqSelectRect()
, and
imaqSelectAnnulus()
to define regions of
interest. Follow these steps to use these functions:
1.
Call the function to display an image in an ROI Constructor window.
Only the tools specific to that function are available for you to use.
2.
Draw an ROI on your image. Resize or reposition the ROI until it
covers the area you want to process.
3.
Click the OK button to populate a structure representing the ROI. You
can use this structure as an input to a variety of functions, such as the
following functions that measure grayscale intensity:
•
imaqLightMeterPoint()
—Uses the output of
imaqSelectPoint()
•
imaqLightMeterLine()
—Uses the output of
imaqSelectLine()
•
imaqLightMeterRect()
—Uses the output of
imaqSelectRect()
Programmatically Defining Regions
When you have an automated application, you may need to define regions
of interest programmatically. To programmatically define an ROI, create
the ROI using
imaqCreateROI()
and then add the individual contours.
A contour is a shape that defines an ROI. You can create contours from
points, lines, rectangles, ovals, polygons, and annuli. For example, to add a
rectangular contour to an ROI, use
imaqAddRectContour()
.
Specify regions by providing basic parameters that describe the region you
want to define. For example, define a point by providing the x-coordinate
and y-coordinate. Define a line by specifying the start and end coordinates.
Define a rectangle by specifying the coordinates of the top, left point; the
width and height; and the rotation angle (in the case of a rotated rectangle).
Defining Regions with Masks
You can define regions to process with image masks. An image mask is
an 8-bit image of the same size as or smaller than the image you want to
process. Pixels in the mask image determine whether the corresponding
pixel in the source image needs to be processed. If a pixel in the image
mask has a value different than 0, the corresponding pixel in the source
image is processed. If a pixel in the image mask has a value of 0, the
corresponding pixel in the source image is left unchanged.