| Image Processing Toolbox | Search  Help Desk |
| nlfilter | Examples See Also |
Perform general sliding-neighborhood operations
Syntax
B = nlfilter(A,[m n],fun) B = nlfilter(A,[m n],fun,P1,P2,...) B = nlfilter(A,'indexed',...)
Description
B = nlfilter(A,[m n],fun) applies the function fun to each m-by-n sliding block of A. fun can be a string containing the name of a function, a string containing an expression, or an inline function object. fun should accept an m-by-n block as input, and return a scalar result:
c = fun(x)
c is the output value for the center pixel in the m-by-n block x. nlfilter calls fun for each pixel in A. nlfilter zero pads the m-by-n block at the edges, if necessary.
B = nlfilter(A,[m n],fun,P1,P2,...) passes the additional parameters P1,P2,..., to fun.
B = nlfilter(A,'indexed',...) processes A as an indexed image, padding with ones if A is of class double and zeros if A is of class uint8.
Class Support
The input imageA can be of any class supported by fun. The class of B depends on the class of the output from fun.
Remarks
nlfilter can take a long time to process large images. In some cases, the colfilt function can perform the same operation much faster.
Example
This call produces the same result as callingmedfilt2 with a 3-by-3 neighborhood:
B = nlfilter(A,[3 3],'median(x(:))');
See Also
blkproc, colfilt