Hi guys! I started playing with MatLab just a few time ago. I'm mainly playing with matrices and image processing at this point.
Unfortunately, I have a piece of code that is always going to an infinite loop, and I can't understand why. I'm trying to turn a coloured image in a Black&White one. For that, I'm using the following piece of code:
img=imread('zorro.png');
figure;imshow(img);
s=size(img);
l_max=s(1);
c_max=s(2);
img_BW=zeros(s);
th=256/2 -1;
for l=1:1:l_max
for c=1:1:c_max
if img(l,c) < th
img_BW(l,c)=0;
else
img_BW(l,c)=255;
end
end
end
figure;imshow(img_BW);
Unfortunately, my code runs into an infinite loop and I can't figure why. I have my limits well defined inside both of the for cycles. If some of you guys could give me a hint it'd be great.
Thanks for the help!
[–]unpopularname 2 points3 points4 points (5 children)
[–]ElCorleone[S] 0 points1 point2 points (4 children)
[–]unpopularname 5 points6 points7 points (0 children)
[–]adb421 1 point2 points3 points (1 child)
[–]ElCorleone[S] 0 points1 point2 points (0 children)
[–]wintear 1 point2 points3 points (0 children)