HOW TO MAKE LINES THIN ENOUGH SUCH THAT THEY ARE 1 PIXEL WIDE?
이전 댓글 표시
suppose i have a square with black edges over a white background. i want to identify the edges such that the index of the edge should of width one pixel. what i did was, first i have converted the image into black and white and then complemented it now when i skeletonize it using 'bwmorph' function infinite times. the edges have become thin of one pixel wide but the corners are getting bent upwards.. i exactly want to get a shape of a square , what should i do??
답변 (2개)
Image Analyst
2013년 10월 16일
0 개 추천
Try using bwboundaries() or bwperim() - see if that gives you what you want.
댓글 수: 1
Image Analyst
2013년 10월 18일
Regarding your "Answer" (which should have been a comment here)...I don't understand what you said about bwboundaries() - it doesn't make sense to me. You have a list of all the coordinates, which you can plot like this:
% bwboundaries() returns a cell array, where each cell contains the row/column coordinates for an object in the image.
% Plot the borders of all the coins on the original grayscale image using the coordinates returned by bwboundaries.
imshow(originalImage);
title('Outlines, from bwboundaries()');
hold on;
boundaries = bwboundaries(binaryImage);
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;
You can call bwperim() and label the square and take the object with the label #1 to get just the outer perimeter.
카테고리
도움말 센터 및 File Exchange에서 Object Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
