Creating 9x9 average filter and applying it to an image with certain values.

27 次查看(过去 30 天)
Hi again, first how to create a 9x9 average filter. I know how to create 3x3 average filter -
>> F = fspecial('average');
But how do I make it to be 9x9?
Also for the boundaries do I just put the value like that(I will show the whole code):
>> I = imread('cameraman.tif');
>> F = fspecial('average');
>> J = imfilter(I,F,255);
The last line creates the boundary to be with value X=255. Also when I do it, why I don't see any change in the picture, it shows the same picture just filtered?

采纳的回答

Image Analyst
Image Analyst 2015-10-19
I told you how to do a 9x9 in your duplicate question. It's just ones(9)/81.
grayImage = imread('cameraman.tif');
subplot(2,1,1);
imshow(grayImage);
title('Original Image', 'FontSize', 15);
blurredImage = imfilter(grayImage, ones(9)/81, 'symmetric');
subplot(2,1,2);
imshow(blurredImage);
title('Blurred Image', 'FontSize', 15);
  3 个评论
Atalay Asa
Atalay Asa 2020-6-7
Do average filter and average mean filter are same thing? Can we use your code for 9x9 arithmetic mean filter?
Image Analyst
Image Analyst 2020-6-7
Yes, as far as I know they're the same. average and mean are just two words for the same thing and doubling them up doesn't really change the meaning. Yes, my code does a 9x9 filter. More generally
grayImage = imread('cameraman.tif');
subplot(2,1,1);
imshow(grayImage);
title('Original Image', 'FontSize', 15);
windowSize = 9; % Whatever you want.
kernel = ones(windowSize, windowSize) / windowSize ^ 2;
blurredImage = imfilter(grayImage, kernel, 'symmetric');
subplot(2,1,2);
imshow(blurredImage);
title('Blurred Image', 'FontSize', 15);

请先登录,再进行评论。

更多回答(2 个)

Santhosh Prasad M
Santhosh Prasad M 2019-1-26
编辑:Santhosh Prasad M 2019-1-26
I = imread('cameraman.tif');
figure,imshow(I);title('Original Image');
C=fspecial('average',[9,9]); %exact 9x9 average filter
d=imfilter(I,C);
figure,imshow(d);title('9x9 average filter');

Simran  Kumari
Simran Kumari 2022-2-10
img = imread('exp3.jpeg');
subplot(2,2,1);
imshow(img);
title('Original Image');
I=rgb2gray(img);
subplot(2,2,2);
imshow(I);
title('gray image');
windowSize = 3; % Whatever you want.
kernel = ones(windowSize, windowSize) / windowSize ^ 2;
d = imfilter(I, kernel, 'symmetric');
subplot(2,2,3);
imshow(d);
title('image after filter');

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by