
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?
댓글 수: 0
채택된 답변
Image Analyst
2015년 10월 19일
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
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
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
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');
댓글 수: 0
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');
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!