Reputation: 1079
How can I use fspecial to apply an averaging filter to the image clown?
I have loaded the clown image into matlab and I have written h=fspecial('average', 3). Now how do I use h to apply the averaging filter to clown?
Upvotes: 0
Views: 419
Reputation: 5821
You use the avgImage = conv2(myImage,h)
function to perform a 2D convolution.
You might consider using h=fspecial('gaussian',[5 5],1)
since gaussians give better blurring results, unless you specifically want to take the average.
Upvotes: 1
Reputation: 104464
Since you have access to fspecial
, that means you have the image processing toolbox. I would recommend you use imfilter
instead, as it is specifically designed to filter images and takes advantages of Intel Integrated Performance Primitives (IIPP) if your processor supports it. Very simply, do:
averageImage = imfilter(inputImage, h);
inputImage
is the image you read in (presumably with imread
), and averageImage
is the output filtered image.
Upvotes: 0