Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR07 / 2read / image processing toolbox guide.pdf
Скачиваний:
166
Добавлен:
18.03.2015
Размер:
18.08 Mб
Скачать

15 Neighborhood and Block Operations

Using Column Processing with Distinct Block Operations

For a distinct block operation, colfilt creates a temporary matrix by rearranging each block in the image into a column. colfilt pads the original image with 0’s, if necessary, before creating the temporary matrix.

The following figure illustrates this process. A 6-by-16 image matrix is processed in 4-by-6 blocks. colfilt first zero-pads the image to make the size 8-by-18 (six 4-by-6 blocks), and then rearranges the blocks into six columns of 24 elements each.

colfilt Creates a Temporary Matrix for Distinct Block Operation

After rearranging the image into a temporary matrix, colfilt passes this matrix to the function. The function must return a matrix of the same size as the temporary matrix. If the block size is m-by-n, and the image is mm-by-nn,

15-28

Using Columnwise Processing to Speed Up Sliding Neighborhood or Distinct Block Operations

the size of the temporary matrix is (m*n)-by-(ceil(mm/m)*ceil(nn/n)). After the function processes the temporary matrix, the output is rearranged into the shape of the original image matrix.

This example sets all the pixels in each 8-by-8 block of an image to the mean pixel value for the block.

I = im2double(imread('tire.tif')); f = @(x) ones(64,1)*mean(x);

I2 = colfilt(I,[8 8],'distinct',f);

The anonymous function in the example computes the mean of the block and then multiplies the result by a vector of ones, so that the output block is the same size as the input block. As a result, the output image is the same size as the input image.

Restrictions

You can use colfilt to implement many of the same distinct block operations that blockproc performs. However, colfilt has certain restrictions that blockproc does not:

The output image must be the same size as the input image.

The blocks cannot overlap.

For situations that do not satisfy these constraints, use blockproc.

15-29

15 Neighborhood and Block Operations

15-30

Соседние файлы в папке 2read