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 件のコメント

Image Analyst
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.

サインインしてコメントする。

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