| Image Processing Toolbox™ | ![]() |
B = nlfilter(A, [m n], fun)
B = nlfilter(A, 'indexed',...)
B = nlfilter(A, [m n], fun) applies the function fun to each m-by-n sliding block of A. fun is a function that accepts an m-by-n matrix as input and returns a scalar result.
c = fun(x)
fun must be a function handle.
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, 'indexed',...) processes A as an indexed image, padding with 1's if A is of class double and 0's if A is of class uint8.
The input image A can be of any class supported by fun. The class of B depends on the class of the output from fun.
nlfilter can take a long time to process large images. In some cases, the colfilt function can perform the same operation much faster.
This example produces the same result as calling medfilt2 with a 3-by-3 neighborhood.
A = imread('cameraman.tif');
fun = @(x) median(x(:));
B = nlfilter(A,[3 3],fun);
imshow(A), figure, imshow(B)blkproc, colfilt, function_handle
![]() | nitfread | normxcorr2 | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |