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??

Antworten (2)

Image Analyst
Image Analyst am 16 Okt. 2013

0 Stimmen

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

1 Kommentar

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.

Melden Sie sich an, um zu kommentieren.

srinivas sri
srinivas sri am 18 Okt. 2013

0 Stimmen

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

Gefragt:

am 16 Okt. 2013

Kommentiert:

am 18 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by