how to apply the arithmetic mean filter to a medical image to improve it? I have wrote this code but it did not work, there is an error which I could not figure it out.
29 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lama Awawdeh
el 20 de Dic. de 2018
Comentada: Jahid Hasan
el 19 de Abr. de 2022
%arithmatic mean filter
im=imread('chest.tif');%loading image
figure,imshow(im);
title('original');
[row col]=size(im);%storing size of image
for i=1:1:row-2;%sweeping through rows
for j=1:1:col-2;%sweeping through columns
for u=1:1:2;%sweeping through window
for v=1:1:2;
%taking arithmetic mean
im(i,j)=im(i,j)+im(i+u,j+v);
im(i,j)=im(i,j)/9;
end
end
end
end
%showing final image
figure,imshow(im);
title('arthmean');
7 comentarios
VISHNU VARDHAN
el 29 de Abr. de 2020
%arithmatic mean filter
clc;
clear all;
close all;
x=imread('1.jpg');
x1=imresize(x,[256,256]);
figure;imshow(x1)
title('original image')%loading image.
x2=rgb2gray(x1);
figure;imshow(x2);title('gray image');
[m,n]=size(x2);%storing size of image.
for i=1:m-3
for j=1:n-3
a=x(i:i+3,j:j+3);
v(i,j)=sum(sum(a));
end
end
y=mat2gray(v);
figure;imshow(y);
title('average image');
this is useful for average of the any hd image.if u want to increase size,change pixcels in imresize command...................
Jahid Hasan
el 19 de Abr. de 2022
Is this loop similar to finding mean as well, how about median, what way I can write a Mexican function? Any suggestions
Respuesta aceptada
KALYAN ACHARJYA
el 20 de Dic. de 2018
Editada: KALYAN ACHARJYA
el 20 de Dic. de 2018
Avoid multiple for loops, use inbuilt imfilter function for masking operation.
The concept is same in all images. For image enhancement you can perform numerous operation depends on input image.
%arithmetic mean filter
im=rgb2gray(imread('chest.tif'));
h=fspecial('average',3);
filter_image=imfilter(im,h);
13 comentarios
Más respuestas (1)
Jan
el 20 de Dic. de 2018
Editada: Jan
el 20 de Dic. de 2018
for u=1:1:2;%sweeping through window
for v=1:1:2;
%taking arithmetic mean
im(i,j)=im(i,j)+im(i+u,j+v);
im(i,j)=im(i,j)/9;
end
end
This is a 2x2 window starting right and top of the current pixel. You divide the result repeatedly by 9. I assume you mean:
for i = 2:row-1
for j = 2:col - 1
a = 0;
for u = -1:1
for v = -1:1
a = a + im(i + u, j + v);
end
end
im(i, j) = a / 9;
end
end
conv2 and filter2 will me more efficient.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!