Problem with tracing boundaries of handwritten letter
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to use the bwtraceboundary function to trace the shape of a handwritten letter. First, I have converted it to binary, used imcomplement to invert the pixels, then dilated and closed the image in order to fill in the gaps, then finally have thinned the image. I got the image showed below.
Now, when I try to use the code below to apply a bwtraceboundary from the point of mouseclick, it gives me this error: 'Attempted to access BW(:,-48); index must be a positive integer or logical'. Can anyone explain why?
Thanks in advance
Debs
The code:
I = imread('image.png');
[x, y] = getpts;
imshow(I)
dim = size(BW)
col = round(dim(2))-90;
row = min(find(BW(:,col)))
boundary = bwtraceboundary(BW,[row, col],'N');
imshow(I)
hold off;
plot(boundary(:,2),boundary(:,1),'b','LineWidth',1);
end
0 个评论
回答(1 个)
Image Analyst
2014-9-22
Why are you using bwtraceboundary? That's only useful if you need to start your boundary at some special particular point. I never use it. I use bwboundaries().
2 个评论
Image Analyst
2014-9-23
Debs "Answer" moved here since it's not an "Answer" to her original question:
Hello, thanks for this! I am trying to trace the outline of the thinned letter shape in order to compare the shape of two different letters. I am trying to get row and column co-ordinates of the boundary pixels in the object. Thanks for your advice, I will give bwboundaries a try today!
Debs
Image Analyst
2014-9-23
But it looks like your image is already skeletonized, and it has branches. I'm not sure of the order and direction that the boundaries will take. For example with a "spur", are the coordinates counted twice, once as it goes out to the tip, and once again on the return trip? Which direction does it take when it hits a 3 or 4 way branch point and will that match up with the direction you expected it to take when you are following strokes for hand written letters?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!