Any help with bwtraceboundary??

2 次查看(过去 30 天)
Sean Farrell
Sean Farrell 2016-10-27
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??

回答(1 个)

Walter Roberson
Walter Roberson 2016-10-27
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)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by