HOW TO MAKE LINES THIN ENOUGH SUCH THAT THEY ARE 1 PIXEL WIDE?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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??
0 Kommentare
Antworten (2)
Image Analyst
am 16 Okt. 2013
Try using bwboundaries() or bwperim() - see if that gives you what you want.
1 Kommentar
Image Analyst
am 18 Okt. 2013
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.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
