code does not seem to work but is not giving any errors
显示 更早的评论
I=imread('phonebox2_noisy.bmp');
a=I;
[row, col, channel]=size(a);
red=a(:,:,1);
green=a(:,:,2);
blue=a(:,:,3);
a1 = red;
a2 = green;
a3 = blue;
for i=2:1:row-1
for j = 2:1:col-1
a1(i,j)= (red(i-1,j-1)+red(i-1,j)+red(i-1,j+1)+red(i,j-1)+red(i,j)+red(i,j+1)+...
red(i+1,j-1)+red(i+1,j)+red(i+1,j+1));
a1=sort(a1);
red(i,j)= a1(5);
a2(i,j)= (green(i-1,j-1)+green(i-1,j)+green(i-1,j+1)+green(i,j-1)+green(i,j)+green(i,j+1)+...
green(i+1,j-1)+green(i+1,j)+green(i+1,j+1));
a2=sort(a2);
green(i,j)= a2(5);
a3(i,j)= (blue(i-1,j-1)+blue(i-1,j)+blue(i-1,j+1)+blue(i,j-1)+blue(i,j)+blue(i,j+1)+...
blue(i+1,j-1)+blue(i+1,j)+blue(i+1,j+1));
a3=sort(a3);
blue(i,j)= a3(5);
end
end
final=cat(3,red,green,blue);
figure;
imshow(a);
title('latte noisy');
figure;
imshow(final);
title('latte');
1 个评论
Benjamin Thompson
2022-1-27
Can you post your bitmap? It runs on the coloredChips.png sample image that comes with MATLAB, though I don't know what the output is supposed to look like. Sometimes bitmaps are not 24 bit color, try using imfinfo on your image.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!