-2

I am trying to link the edges in images like the image below:

Broken Edges

I've tried using dilation/erosion operations but the result isn't good. Is there any other way to link the edges?

Here is the original image:

Original Image

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Katerina T
  • 15
  • 5

1 Answers1

1

The result you have might very well be good enough to apply the Hough transform to, which will identify your eight most important lines across the image.

I don't know if all your images are similar, but in the example you show it is easy to separate the gray lines from the green background. For example, the following code (using DIPimage, but easy to implement with other tools too) will distinguish the relatively bright gray from anything that is dark or colorful:

img = readim('https://i.stack.imgur.com/vmBiF.jpg');
img = colorspace(img,'hsv');
img = (0.5-img{2})*img{3}; % img{2} is the saturation channel, img{3} is the value (intensity) channel
img = clip(img);           % set negative values to 0

output of first code snippet

Next, a Laplace of Gaussian filter (which is a line detector), some thresholding just above zero, and a selection of only the larger objects results in the detected lines:

img = -laplace(img,5);       % LoG with sigma=5
img = img > 0.05;            % 0.05 is just above 0
img = areaopening(img,1000); % remove objects smaller than 1000 pixels

output of second code snippet

Needless to say, this is a lot cheaper computationally than running a U-Net.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120