Embedded Image Processing on the TMS320C6000 DSP: Examples in Code Composer Studio and MATLAB

4.2: Linear Filtering of Images in Matlab

4.2 Linear Filtering of Images in Matlab

The Image Processing Toolbox includes a function imfilter that can be used to filter images. The first argument to this function is the image matrix, and the second argument is a matrix containing the filter coefficients. The command

J = imfilter(I, ones(3,3)./9);

passes the image I through a 3x3 averaging filter. The ones function returns a constant matrix of ones. There is another similar MATLAB function zeros that returns the zero matrix - both of these functions are useful for preallocating space for matrices and initialization of matrix values. The . / operator specifies element-wise division, so the second argument above passes into imfilter a 3x3 matrix where each element is 1/9. The imfilter command also allows one to specify how to handle edge pixels with an optional third argument, and a variety of other options are available (refer to the online help for more information).

The Image Processing Toolbox function fspecial can be used to generate 2D kernels for use with imfilter. This function is especially helpful, as it knows about a slew of common filters, all of which can be tuned according to kernel size and additional filter-specific parameters. The first argument to fspecial is a string indicating which class of filter to generate (refer to the online help for a full list of supported filter types), the second argument is the size of the kernel, and the rest are optional arguments...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Active High Pass Filters
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.