Columnwise neighborhood operations
B = colfilt(A,[m n],
block_type
,fun)
B = colfilt(A,[m n],[mblock nblock],block_type,fun)
B = colfilt(A,'indexed',...)
B = colfilt(A,[m n],
processes
the image block_type
,fun)A
by rearranging each m
byn
block
of A
into a column of a temporary matrix, and then
applying the function fun
to this matrix. fun
must
be a function handle. Parameterizing Functions, in the MATLAB Mathematics
documentation, explains how to provide additional parameters to the
function fun
. The function colfilt
zeropads A
,
if necessary.
Before calling fun
, colfilt
calls im2col
to
create the temporary matrix. After calling fun
, colfilt
rearranges
the columns of the matrix back into m
byn
blocks
using col2im
.
block_type
is a string that can have
one of the values listed in this table.
Note:

Value  Description 

 Rearranges each 
 Rearranges each 
B = colfilt(A,[m n],[mblock nblock],block_type,fun)
processes
the matrix A
as above, but in blocks of size mblock
bynblock
to
save memory. Note that using the [mblock nblock]
argument
does not change the result of the operation.
B = colfilt(A,'indexed',...)
processes A
as
an indexed image, padding with 0's if the class of A
is uint8
or uint16
,
or 1's if the class of A
is double
or single
.
Note
To save memory, the 
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
.
Set each output pixel to the mean value of the input pixel's 5by5 neighborhood.
I = imread('tire.tif'); I2 = uint8(colfilt(I,[5 5],'sliding',@mean)); figure subplot(1,2,1), imshow(I), title('Original Image') subplot(1,2,2), imshow(I2), title('Filtered Image')
blockproc
 col2im
 function_handle
 im2col
 nlfilter