GrayMorphology Method

NI Vision for Visual Basic

GrayMorphology Method

Syntax

CWIMAQVision.GrayMorphology SourceImage, DestImage, Operation [, StructuringElement]

Return Type

Long

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

Purpose

Applies morphological transformations to gray level images.

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.

SourceImage and DestImage must be the same type of image. The calculation modifies the border of the source image. The source image for a morphological transformation must have been created with a border capable of supporting the size of the structuring element. A 3 x 3 structuring element requires a minimal border of 1, a 5 x 5 structuring element requires a minimal border of 2, and so on. The border size of the destination image is not important.

A structuring element must have odd-sized dimensions so that it contains a central pixel. If one of the dimensions for the structuring element is even, the function does not take into account the odd boundary, farthest out on the matrix. For example, if the input structuring element is 6 × 4 (Width = 6 and Height = 4), the actual processing is performed at 5 x 3. Both the sixth line and the fourth row are ignored. The processing speed is correlated with the size of the structuring element. For example, a 3 x 3 structuring element processes nine pixels, and a 5 × 5 structuring element processes 25 pixels.

This function is optimized for MMX.

Parameters

SourceImage As CWIMAQImage

The image on which the method performs the morphological operation.

DestImage As CWIMAQImage

The resulting image.

Operation As CWIMAQGrayMorphOperations

The type of morphological transformation procedure to use.

StructuringElement As Variant

[Optional] A CWIMAQStructuringElement object that describes the structuring element applied to the image. The method applies a 3 x 3 structuring element if you do not set this parameter.

Example

Dim i As New CWIMAQImage
Dim structuringElement As New CWIMAQStructuringElement

' Perform a POpen operation on the image in Viewer1.
' Store the result in i.
CWIMAQVision1.GrayMorphology CWIMAQViewer1.Image, i, _
                             cwimaqGrayMorphPOpen, structuringElement

See Also

CWIMAQStructuringElement