Tracing one line image

조회 수: 11 (최근 30일)
anouar atmn
anouar atmn 2021년 12월 22일
편집: Image Analyst 2021년 12월 22일
Hi,
I need to trace a oneline image for a project. A one line image is an drawing/image made with just one line. Im trying to write a code that traces the line and exports this to x y coordinates, (an array). Does anyone have a clue how to do this?
Thank you!!

답변 (2개)

Matt J
Matt J 2021년 12월 22일
편집: Matt J 2021년 12월 22일
One way would be to use bwconvhull.
[x1,y1, x2,y2]=deal(5,6, 13,14); %the two end points
BW=false(20);
BW(y1,x1)=1;
BW(y2,x2)=1;
BW=bwconvhull(BW);
imshow(BW)
  댓글 수: 3
Matt J
Matt J 2021년 12월 22일
편집: Matt J 2021년 12월 22일
I don't know what you mean by a complicated line. A line is a line (or rather a line segment) if and only if it is the convex hull of two points.
anouar atmn
anouar atmn 2021년 12월 22일
This is an example of what im trying to trace

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


Image Analyst
Image Analyst 2021년 12월 22일
편집: Image Analyst 2021년 12월 22일
I'd first call edge with 'Canny' to get your edges. Then I'd label the edges so that you draw each edge one at a time
[labeledEdges, numCurves] = bwlabel(edgeImage);
Then for each one, get the coordinates and put them in a loop to draw them
hold on; % Don't let plotting blow away image.
for k = 1 : numCurves
thisCurve = ismember(labeledEdges, k);
[rows, columns] = find(thisCurve);
for k2 = 1 : length(rows)
plot(columns(k2), rows(k2), 'r.', 'MarkerSize', 10)
drawnow;
pause(0.2);
end
end
hold off;

Community Treasure Hunt

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

Start Hunting!

Translated by