How can I connect the white dots in a binary image like this?

조회 수: 3 (최근 30일)
Jannie Sy
Jannie Sy 2016년 3월 6일
댓글: Image Analyst 2018년 1월 18일
How can I connect the white dots in a binary image like this?
These are edge points detected in an image.

답변 (1개)

Image Analyst
Image Analyst 2016년 3월 6일
You might want to adjust your edge detection parameters first to get a better image. Other than that you can use a for loop to find the closest point to each point and use linspace() to find a path between them, then burn those points into the image
For each dot pair you've identified:
distance = sqrt((x2-x1)^2+(y2-y1)^2)
spacing = 0.4; % pixels between dots (to make sure we don't skip any)
numPoints = distance/spacing;
xLine = linspace(x1, x2, numPoints);
yLine = linspace(y1, y2, numPoints);
rows = round(yLine);
columns = round(xLine);
for k = 1 : length(xLine)
edgeImage(rows(k), columns(k)) = true;
end
  댓글 수: 2
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2018년 1월 18일
@Image Analyst I have the same problem. Is it possible to use all points together without using for loop that means one pair point(x1,y1) and (x2,y2) ;
Image Analyst
Image Analyst 2018년 1월 18일
Not that I know of. What's wrong with a loop? It should be fast, like less than a millisecond.

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

Community Treasure Hunt

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

Start Hunting!

Translated by