unknown_
asked on
bwtraceboundary
Hello,
Can someone explain me what the following code does ?
Thanks in advance !
Can someone explain me what the following code does ?
Thanks in advance !
BW = imread('blobs.png');
imshow(BW,[]);
s=size(BW);
for row = 2:55:s(1)
for col=1:s(2)
if BW(row,col),
break;
end
end
contour = bwtraceboundary(BW, [row, col], 'W');
here is a demo using bwtracebounday
http://www.mathworks.com/products/image/demos.html?file=/products/demos/shipping/images/ipexangle.html#6
http://www.mathworks.com/products/image/demos.html?file=/products/demos/shipping/images/ipexangle.html#6
ASKER
can someone explain what's the purpose of that for loop in the code ?
for row = 2:55:s(1)
for col=1:s(2)
if BW(row,col),
break;
end
end
for row = 2:55:s(1)
for col=1:s(2)
if BW(row,col),
break;
end
end
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.mathworks.com/access/helpdesk/help/toolbox/images/bwtraceboundary.html
You show here only part of the code. The full code is below. What the code does is there as well:
Read in and display a binary image. Starting from the top left, project a beam across the image searching for the first nonzero pixel. Use the location of that pixel as the starting point for the boundary tracing. Including the starting point, extract 50 pixels of the boundary and overlay them on the image. Mark the starting points with a green x. Mark beams that missed their targets with a red x.
Do you need line-by-line description? Which lines you don't understand exactly?
Open in new window