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
Image Analyst 2013년 10월 16일

0 개 추천

Try using bwboundaries() or bwperim() - see if that gives you what you want.

댓글 수: 1

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.

댓글을 달려면 로그인하십시오.

srinivas sri
srinivas sri 2013년 10월 18일

0 개 추천

what if the image is like this square ,bwboundaries() is giving in terms of cell format not possible to display the image or represnt in terms of a matrix , while bwperim() is giving an image of double lined square,but i just want the outer perimeter continous not discrete of one pixel thick......

질문:

2013년 10월 16일

댓글:

2013년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by