Problem with tracing boundaries of handwritten letter

조회 수: 1 (최근 30일)
Deborah
Deborah 2014년 9월 22일
편집: Walter Roberson 2015년 12월 14일
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

답변 (1개)

Image Analyst
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
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
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 CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by