Any help with bwtraceboundary??
2 views (last 30 days)
Show older comments
rot = imrotate(image2,90);
h = imshow(rot,[]);
hp = impixelinfo;
set(hp,'Position',[5 1 300 20]);
% these lines display the pixel info at any point on the grid. I need to
% manually hover over a random point at the edge of a solid region, acquire
% the row and column point, and then use this in the boundary-trace
% function
r = 152;
c = 104;
trace = bwtraceboundary(rot,[r c],'W',8,Inf,'clockwise');
hold on;
plot(trace(:,2),trace(:,1),'g','LineWidth',2);
end
Hi folks, I am trying to write a script using bwtraceboundary. My image processing is correct in that I have a binary logic matrix. The real confusing part of this is down at the bottom of the code where I am trying to use the bwtraceboundary function. I keep getting an error stating index exceeds matrix dimensions because the trace variables ends up resulting as an open vector []. Any thoughts??
0 Comments
Answers (1)
Walter Roberson
on 27 Oct 2016
Try
[r, c] = find(rot, 1, 'first');
You will probably need to use 'E' or 'NE' rather than 'W' as there will definitely not be anything 'W' of the point it finds this way (it will be the west-most point)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!