Image Processing Toolbox    
blkproc

Implement distinct block processing for an image

Syntax

Description

B = blkproc(A,[m n],fun) processes the image A by applying the function fun to each distinct m-by-n block of A, padding A with zeros if necessary. fun is a function that accepts an m-by-n matrix, x, and return a matrix, vector, or scalar y.

blkproc does not require that y be the same size as x. However, B is the same size as A only if y is the same size as x.

B = blkproc(A,[m n],fun,P1,P2,...) passes the additional parameters P1,P2,..., to fun.

B = blkproc(A,[m n],[mborder nborder],fun,...) defines an overlapping border around the blocks. blkproc extends the original m-by-n blocks by mborder on the top and bottom, and nborder on the left and right, resulting in blocks of size (m+2*mborder)-by-(n+2*nborder). blkproc pads the border with zeros, if necessary, on the edges of A. fun should operate on the extended block.

The line below processes an image matrix as 4-by-6 blocks, each having a row border of 2 and a column border of 3. Because each 4-by-6 block has this 2-by-3 border, fun actually operates on blocks of size 8-by-12.

B = blkproc(A,'indexed',...) processes A as an indexed image, padding with zeros if the class of A is uint8 or uint16, or ones if the class of A is double.

Class Support

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.

Example

fun can be a function_handle created using @. This example uses blkproc to compute the 2-D DCT of each 8-by-8 block to the standard deviation of the elements in that block.

fun can also be an inline object. This example uses blkproc to set the pixels in each 8-by-8 block to the standard deviation of the elements in that block.

See Also

colfilt, nlfilter, inline


 bestblk brighten