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!