Reputation: 3
i want to find black pixel positions and save them. i used this code.
I= imread('bin_ecgm.png');
imshow(I);
[r c] =size(I);
for j=1:c
for i=1:r
if(I(i,j)==1)
[i j]
end
end
end
how to store black pixel positions
Upvotes: 0
Views: 412
Reputation: 114786
usually black pixels are I( ii, jj ) == 0
... you can do that without a loop
[ii jj] = find( I == 0 ); % or I == 1 if you insist...
PS,
It is best not to use i
and j
as variable names in Matlab.
Upvotes: 3