EdgeFilter Method

NI Vision for Visual Basic

EdgeFilter Method

Syntax

CWIMAQVision.EdgeFilter SourceImage, DestImage, EdgeMethod [, Threshold = 0] [, MaskImage]

Return Type

Long

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

Purpose

Extracts the contours (detects edges) in gray-level values.

Remarks

This method modifies the source image. If you need the original source image, create a copy of the image using the CWIMAQVision.Copy method before using this method.

Use this method with U8, I16 and SGL images. MaskImage must be a U8 image. SourceImage and DestImage must be the same type of image. The source image must have a border capable of supporting the size of the processing matrix. For example, a 3 x 3 matrix has a minimum border size of 1. The border size of the destination image is not important.

Parameters

SourceImage As CWIMAQImage

The input image.

DestImage As CWIMAQImage

The resulting image.

EdgeMethod As CWIMAQGrayEdgeMethods

Specifies the type of edge-detection filter to use.

Threshold As Variant

[Optional] Specifies the minimum pixel value to appear in the resulting image. It is rare to use a value greater than 0 for this type of processing because the results from this processing are usually very dark and are not very dynamic.

This parameter has a default value of 0.

MaskImage As Variant

[Optional] A CWIMAQImage object that contains the mask applied to the source image. 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 apply the filter to the entire image.

Example

Dim i As New CWIMAQImage
Dim maskImage As New CWIMAQImage

' Apply a Sobel filter to a portion of the image in Viewer1
' defined by regions selected on Viewer1.
' Store the result in i.
CWIMAQVision1.RegionsToMask maskImage, CWIMAQViewer1.Regions
CWIMAQVision1.EdgeFilter CWIMAQViewer1.Image, i, _
                         cwimaqGrayEdgeSobel, , maskImage