Taking the median filter of two images
Mostrar comentarios más antiguos
Hello all,
I'm doing an image processing problem where I'm solving a regularized l1 minimization problem for x_n where N is a 3x3 neighborhood around a given pixel
to solve this you get that x_n=median([
]) the concatination of the neighborhood from the original image and your previous iteration x_n-1.
]) the concatination of the neighborhood from the original image and your previous iteration x_n-1.I didn't know how to solve this with any built in matlab codes so I just made my own.
The problem is that it's pretty inefficient and I was wondering if you peeps had any suggestions!
here's my code. (note: I didn't/don't really care about the boundy of the image)
for nnn=1:50
I_noisy_update = I_noisy1;
for m=2:size(I_noisy1,1)-1
for n=2:size(I_noisy1,2)-1
neighborhood1 = I_noisy1(m-1:m+1,n-1:n+1); % getting the neighborhood of my original image
neighborhood1 = neighborhood1(:);
neighborhood_orig = I_noisy(m-1:m+1,n-1:n+1); % getting the neighborhood of my updated image
neighborhood_orig=neighborhood_orig(:);
neighborhood = [neighborhood_orig;neighborhood1]; % concatinating the two
I_noisy_update(m,n) = median(neighborhood); % getting this median
end
end
I_noisy1 = I_noisy_update; % update my solution
end
Respuestas (1)
Pavan Guntha
el 25 de Mzo. de 2021
0 votos
You can refer to the documentation of medfilt2 function which is a part of Image processing toolbox which performs median filtering of an image in two dimensions.
1 comentario
tiwwexx
el 25 de Mzo. de 2021
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!