Columnwise neighborhood operations
B = colfilt(A,[m n],
B = colfilt(A,[m n],[mblock nblock],block_type,fun)
B = colfilt(A,'indexed',...)
B = colfilt(A,[m n], processes
A by rearranging each
A into a column of a temporary matrix, and then
applying the function
fun to this matrix.
be a function handle. The function
create the temporary matrix. After calling
the columns of the matrix back into
block_type is one of the values listed
in this table.
colfilt can perform operations similar to
but often executes much faster.
B = colfilt(A,[m n],[mblock nblock],block_type,fun) processes
A as above, but in blocks of size
save memory. Note that using the
[mblock nblock] argument
does not change the result of the operation.
B = colfilt(A,'indexed',...) processes
an indexed image, padding with 0's if the class of
or 1's if the class of
To save memory, the
colfilt function might
A into subimages and process one subimage
at a time. This implies that
fun may be called
multiple times, and that the first argument to
have a different number of columns each time.
The input image
A can be of any class supported
fun. The class of
on the class of the output from
This example shows how to set each output pixel to the mean value of the input pixel's 5-by-5 neighborhood using columnwise neighborhood processing.
Read a grayscale image into the workspace.
I = imread('tire.tif');
Perform columnwise filtering. The function
mean is called on each 5-by-5 pixel neighborhood.
I2 = uint8(colfilt(I,[5 5],'sliding',@mean));
Display the original image and the filtered image.
imshow(I) title('Original Image')
figure imshow(I2) title('Filtered Image')