How can I connect the white dots in a binary image like this?
3 次查看(过去 30 天)
显示 更早的评论
How can I connect the white dots in a binary image like this?

These are edge points detected in an image.
0 个评论
回答(1 个)
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
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
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!