Replacing pixel value in a loop
显示 更早的评论
Hi everyone, Im trying to replace all pixels in rbg image, where the sum of r,g,b components is lower or equal 10 with zero value ([r,b,g]=[0,0,0]) .
If not I want to keep the value from MyImage.
Here is my attempt ...unfortunately not working
MyImage=imread('003264663547_60.jpeg');
RGBsum=(sum(MyImage,3));
NewImage = zeros(size(MyImage));
[a b c]= size(NewImage);
[row column depth]=size(MyImage);
for l=1:depth
for i=1:row
for j=1:column,
if RGBsum <= 10;
NewImage(a,b,c)=0;
else
NewImage(a,b,c)=MyImage(row,column,depth);
end
end
end
end
imshow(NewImage);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!