Taking the median filter of two images
4 次查看(过去 30 天)
显示 更早的评论
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.
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
0 个评论
回答(1 个)
Pavan Guntha
2021-3-25
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!