Replacing pixel value in a loop
Afficher commentaires plus anciens
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);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!