Connect edges in binary image

Dear community,
I segmented image 1 to obtain to obtain image 2 (refer to the attachements). However I would like to connect the broken edges to obtain image no. 3 (connected edges are exemplified in red). Would you kindly have any suggestion? In case it may be of your interest, I also have the possibility to segment image 1 to obtain image 4.
Besides this, if you have any idea to fit the white edges into lines, it would be more than welcome!
Best2.png

Respuestas (1)

Subhadeep Koley
Subhadeep Koley el 3 de Feb. de 2020
After binarizing the image you can use the function bwmorph() to make a bridge between the white lines present in the image.
After bridging if you like you can use the function imdilate() to enhance the connected line. You can tweak various parameters of the function to get your desired output.
close all; clc;
a = imread('2.png');
a = imbinarize(a); % Binarize the image
b = bwmorph(a, 'bridge'); % Use this to connect the pixels
se = strel('line', 20, 180); % Structuring element for dilation
b = imdilate(b, se); % Dilating the image
imshow(b);
connEdges.png
See if this is your expected result.

3 comentarios

Santi
Santi el 3 de Feb. de 2020
Thank you foryour effort and the good results. However, the lines are not completely connected (e.g. refer to the 45 degree ligaments, between others).
Subhadeep Koley
Subhadeep Koley el 3 de Feb. de 2020
Yes, it is difficult to connect all the lines completely. However, as I said you can always tweak the dilation structures for your optimum result.
Santi
Santi el 3 de Feb. de 2020
Thank you! But I was thinking on something more automatic (I have multiple images to post-process).

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 3 de Feb. de 2020

Comentada:

el 3 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by