Morphology Method

NI Vision for Visual Basic

Morphology Method

Syntax

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

Return Type

Long

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

Purpose

Performs primary morphological transformations.

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.

All source and destination images must be U8 images.

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.

This method is optimized for MMX.

Parameters

SourceImage As CWIMAQImage

The image on which the method performs the morphological operations.

DestImage As CWIMAQImage

The resulting image.

Operation As CWIMAQMorphOperations

The type of morphological transformation 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 supply this parameter.

Example

Private Sub Run_Click()
    Dim i As New CWIMAQImage
    Dim structuringElement As New CWIMAQStructuringElement
    
    ' Threshold the image in Viewer1 to make it a binary image.
    CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _
                            128, 255, , 255
    
    ' Perform a POpen operation on the image in Viewer1.
    ' Store the result in i.
    CWIMAQVision1.Morphology CWIMAQViewer1.Image, i, _
                             cwimaqGrayMorphPOpen, structuringElement
    
    ' Display the result in Viewer2 using a binary palette.
    CWIMAQViewer2.Attach i
    CWIMAQViewer2.Palette.Type = cwimaqPaletteBinary
End Sub

See Also

CWIMAQStructuringElement