LabKit MATLAB Workbench

reference

API ReferenceImage API

labkit.image.meanFilter2

Apply normalized 2-D mean filtering with edge correction.

Syntax

imageOut = labkit.image.meanFilter2(imageIn, windowSize)

Description

Replaces each sample with the arithmetic mean of the rectangular neighborhood that overlaps the image. At an edge or corner, the divisor is reduced to the number of available samples instead of assuming zero padding. Each channel of a 3-D image is filtered independently.

windowSize is rounded to an integer and limited to at least 1. Both odd and even widths are accepted; conv2 determines the alignment of an even window. Input is converted to double for calculation. NaN values are not omitted and therefore propagate to neighborhoods that include them.

Inputs

imageIn
2-D image matrix or 3-D image with channels in dimension 3.
windowSize
Numeric scalar neighborhood width in pixels.

Outputs

imageOut
Double array with the same size as imageIn.

Failure Behavior

imageIn must be compatible with double and conv2, and windowSize must be convertible to one numeric scalar. Unsupported types, sparse arrays, or nonscalar window values raise the originating MATLAB error.

Example

impulse = [0 0 0; 0 1 0; 0 0 0];
smoothed = labkit.image.meanFilter2(impulse, 3);

Source

This page is generated from the MATLAB help text in +labkit/+image/meanFilter2.m.