matlabimage-processingintersectioncurves

Find the intersections of a series of curves of an image: Matlab


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.


Solution

  • 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