NthOrder Method

NI Vision for Visual Basic

NthOrder Method

Syntax

CWIMAQVision.NthOrder SourceImage, DestImage [, XFilterSize = 3] [, YFilterSize = 3] [, OrderNumber = 4] [, MaskImage]

Return Type

Long

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

Purpose

Filters an image using a nonlinear filter. For each pixel, the algorithm takes the neighborhood specified by the given filter sizes and replaces the pixel with the nth smallest value in the neighborhood.

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.

The filter modifies the border of the source image. The connected source image must have been created with a border capable of supporting the size of the convolution matrix. A 3 x 3 matrix must have a minimum border of 1, a 5 x 5 matrix must have a minimum 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 to filter.

DestImage As CWIMAQImage

The resulting image.

XFilterSize As Variant

[Optional] The size of the horizontal matrix axis. This number must be odd.

This parameter has a default value of 3.

YFilterSize As Variant

[Optional] The size of the vertical matrix axis. This number must be odd.

This parameter has a default value of 3.

OrderNumber As Variant

[Optional] The value in the neighborhood to place in the destination. Set this parameter to 0 to select the smallest value in the neighborhood, 1 to select the next smallest value, and so on.

This parameter has a default value of 4.

MaskImage As Variant

[Optional] A CWIMAQImage object that contains the mask applied to the source image. It indicates the region of the image in which the method applies the NthOrder filter. 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 filter the entire image.

Example

Dim i As New CWIMAQImage
Dim maskImage As New CWIMAQImage

' Apply a Nth order 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.NthOrder CWIMAQViewer1.Image, i, , , 5, _
                       maskImage