4

I have an image with a series of lines, like below:

lines example

I would like to know if there is some method for finding the intersections of all of the lines.

I was checking another post where they offer a way to find the intersections, but once the image is segmented I suppose it has noise or something similar... I will start with a simple image to find each intersection.

My main idea was to solve the "system of equations" but I think for an image with many intersections would be too difficult, I do not know if there is any method to find all intersections.

Wolfie
  • 27,562
  • 7
  • 28
  • 55
AlexZ
  • 229
  • 1
  • 8
  • Do you have the equations of the lines, or are you analysing an image? – Wolfie May 07 '17 at 22:59
  • 1
    I am analyzing an image but I am starting from simple examples to give me an idea of ​​how to do it with an uncontrolled image – AlexZ May 08 '17 at 14:03

1 Answers1

5

I assume you don't have the line equations. I used skeletonization and filtering to detect small areas with more than one line crossing them. I'm not sure that it will be so simple for noisy image but it worth trying:

im = im2double(rgb2gray(imread('lines.png')));
% binarize black lines
bw = im == 0;
% skelatonize lines
sk = bwmorph(bw,'skel',inf);
% filter skeleton with 3X3 ones filter
A = imfilter(double(sk),ones(3));
% find blobs greater than 4 - more than one line crossing the filter
B = A > 4;
% get centroids of detected blobs
C = regionprops(B,'Centroid');
Cent = reshape([C.Centroid],2,[]).';
% plot
imshow(im)
hold on;
plot(Cent(:,1),Cent(:,2),'gx','LineWidth',2)

enter image description here

user2999345
  • 4,195
  • 1
  • 13
  • 20