Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Filter Multidimensional Images with imfilter

This example shows how to filter a multidimensional truecolor image using imfilter. Filtering a three-dimensional image with a two-dimensional filter is equivalent to filtering each plane of the three-dimensional image individually with the same two-dimensional filter.

Read truecolor image.

rgb = imread('peppers.png');
imshow(rgb);

Create a filter.

h = ones(5,5)/25
h =

    0.0400    0.0400    0.0400    0.0400    0.0400
    0.0400    0.0400    0.0400    0.0400    0.0400
    0.0400    0.0400    0.0400    0.0400    0.0400
    0.0400    0.0400    0.0400    0.0400    0.0400
    0.0400    0.0400    0.0400    0.0400    0.0400

Filter the image using imfilter and display it.

h = ones(5,5)/25;
rgb2 = imfilter(rgb,h);
figure, imshow(rgb2)

Was this topic helpful?