Processes image in blocks using user-supplied function.
B=blockproc(A,[m,n],fun)
divides image A in
m-by-n blocks, and passes them to user-supplied function
fun, which result is concatenated to build returning matrix
B. If padding is needed to build m-by-n, it is added
at the bottom and right borders of the image. 0 is used as a padding
value.
B=blockproc(A,[m,n],fun, …)
behaves as described above but
passes extra parameters to function fun.
B=blockproc(A,[m,n],[mborder,nborder],fun, …)
behaves as
described but uses blocks which overlap with neighbour blocks.
Overlapping dimensions are mborder vertically and nborder
horizontally. This doesn’t change the number of blocks in an image
(which depends only on size(A) and [m,n]). Adding a
border requires extra padding on all edges of the image. 0 is used as
a padding value.
B=blockproc(A,'indexed', …)
assumes that A is an indexed
image, so it pads the image using proper value: 0 for uint8 and
uint16 images and 1 for double images. Keep in mind that if ’indexed’
is not specified padding is always done using 0.
See also: colfilt,inline,bestblk.
The following code
blockproc (eye (6), [2, 2], @(x) any (x(:))) # Returns a 3-by-3 diagonal
Produces the following output
ans = 1 0 0 0 1 0 0 0 1
Package: image