How can I connect the white dots in a binary image like this?
6 views (last 30 days)
Show older comments
How can I connect the white dots in a binary image like this?
These are edge points detected in an image.
0 Comments
Answers (1)
Image Analyst
on 6 Mar 2016
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 Comments
K M Ibrahim Khalilullah
on 18 Jan 2018
@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
on 18 Jan 2018
Not that I know of. What's wrong with a loop? It should be fast, like less than a millisecond.
See Also
Categories
Find more on Visual Exploration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!