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

6 visualizaciones (últimos 30 días)
Jannie Sy
Jannie Sy el 6 de Mzo. de 2016
Comentada: Image Analyst el 18 de En. de 2018
How can I connect the white dots in a binary image like this?
These are edge points detected in an image.

Respuestas (1)

Image Analyst
Image Analyst el 6 de Mzo. de 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 comentarios
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah el 18 de En. de 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
Image Analyst el 18 de En. de 2018
Not that I know of. What's wrong with a loop? It should be fast, like less than a millisecond.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by