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

27 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Image Analyst
Image Analyst el 19 de Oct. de 2015
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 comentarios
Atalay Asa
Atalay Asa el 7 de Jun. de 2020
Do average filter and average mean filter are same thing? Can we use your code for 9x9 arithmetic mean filter?
Image Analyst
Image Analyst el 7 de Jun. de 2020
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);

Iniciar sesión para comentar.

Más respuestas (2)

Santhosh Prasad M
Santhosh Prasad M el 26 de En. de 2019
Editada: Santhosh Prasad M el 26 de En. de 2019
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 el 10 de Feb. de 2022
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');

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by