ColorToGreyscaleFilter
Available for color In-Sight sensors and color-enabled emulators only, ColorToGreyscaleFilter converts each pixel in a color image or region of interest (ROI) to a greyscale value based on a simple filter of one color parameter: "pure" red, green or blue (RGB); hue, saturation or intensity (HSI); luminance; or interpolation of the weighted average of RGB components. For more information, see Color Components of a Pixel.
ColorToGreyscaleFilter Inputs
Syntax: ColorToGreyscaleFilter(Image,Fixture.Row,Fixture.Column,Fixture.Theta,Region.X,Region.Y,Region.High,Region.Wide,Region.Angle,Conversion,Show)
Parameter | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
This argument must reference a spreadsheet cell that contains a valid color Image data structure. By default, the cell referenced isA0, the cell containing the Image data structure returned by AcquireImage. For more information, see AcquireImage. Note: : AcquireImage is the only function that returns a valid color Image data structure.
|
|||||||||||||||||
Defines the ROI relative to a Fixture input or the output of a VisionTool function's image coordinate system. Setting the ROI relative to a fixture ensures that if the fixture is rotated or translated, the ROI will be rotated or translated in relation to the fixture. Note: The default setting is (0,0,0), the top leftmost
corner of the image. For more information on Fixture, see Fixture. For more information on VisionTools, see Vision Tools.
|
|||||||||||||||||
Also known as the region of interest or ROI, specifies the region of the image that undergoes image processing; creates a rectangular image region that can be transformed and rotated. With this parameter selected, clicking the MaximizeRegion button will automatically stretch the region to cover the entire image.
|
|||||||||||||||||
Specifies the type of conversion filter. Note:
|
|||||||||||||||||
Specifies which graphical overlays are displayed on top of the image.
|
ColorToGreyscaleFilter Outputs
Returns |
An Image data structure containing the processed image, or #ERR if any of the input parameters are invalid. For more information, see Structures. |
ColorToGreyscaleFilter Example
In this example, the object in the input image is a yellow Cognex sensor, which is also used in the example for GreyscaleDistance. Random samplings of the image (achieved by toggling off the Overlay view by choosing Overlay on the View menu, moving the cursor over the sensor and viewing the RGB information in the status bar in the bottom-left corner of the window) reveal RGB values of 205-185-124, 193-177-110, 175-154-39, 133-104-2 and 115-91-6 for the sensor. For more information on GreyscaleDistance, see GreyscaleDistance.
After inserting the function into the In-Sight spreadsheet, the user defines the ROI by double-clicking on the word "Region" in the property sheet, which disappears to reveal the red ROI box overlaid on the image. The user moves or resizes the box using the cursor and clicks the green "checkmark" icon in the In-Sight toolbar (or presses the Enter key on the keyboard) to confirm the selection and return to the property sheet.
Selecting a conversion filter, accepting the default settings of the other parameters and clicking OK in the property sheet completes the configuration for this example and applies the function to the input image.
Below are three output images of the red, green and blue filters applied, respectively. As expected, the yellow of the sensor is brightest in the red-filtered image because red is the strongest color component in the yellow sensor.(The maximum red value for the image is 210, the mean is 116 and the median is 127.) The closer the input pixel value is to the filter's value, the brighter the output pixel.
The yellow of the sensor is slightly darker in the green-filtered image because it contains less green (maximum of 199, mean of 112 and median of 125), compared with red.
The yellow of the sensor is darkest in the blue-filtered image because it contains little blue (maximum of 197, mean of 101 and median of 121), compared with red.