How to find intersections in binary image lines?

I have a binary image with curved lines as shown below, but I would like to know how I can find where they will intersect if they are expanded.

So, could you give me a few words about how I could:

  • expand the end points of the line in one direction,
  • How to find the intersection?

I was thinking about using the hough transform to find lines, then intersections, but in some images my endpoints of the line are not quite straight. Is there a way, perhaps, to find only the direction of the line at the end, and not along the entire line, since this is a binary image?

Thanks for any help cab

+6
source share
6 answers

Applying dilatation and then erosion will extend your endpoints as follows:

(*Code in Mathematica*) Erosion[Dilation[i, 10], 10] 

enter image description here

A complete solution might be something like this:

 r = Dilation[MorphologicalBranchPoints[ Thinning[ Binarize@Erosion [Dilation[i, 10], 10], 10]] // Colorize, 3] ImageAdd[i, r] 

enter image description here

+4
source

I think you should take a look at Hough Transformation . It calculates the equation of lines from a binary redistribution (usually the output of a edge detector). Once you have this, piece of cake to calculate the intersection.

+4
source

You can try to establish three corresponding curves, and then solve the equation for the two intersections explicitly.

There are some established models for curve fitting.

+3
source

Here is what I came up with with Hough Transform:

 %# read and binarize image I = imread('http://i.stack.imgur.com/XlxmL.jpg'); BW = im2bw(rgb2gray(I)); %# hough transform, detect peaks, then get lines segments [HTR] = hough(BW, 'Theta',-10:10); %# specific theta range P = houghpeaks(H, 5); lines = houghlines(BW, T, R, P); %# overlay detected lines over image figure, imshow(BW), hold on for k = 1:length(lines) xy = [lines(k).point1; lines(k).point2]; plot(xy(:,1), xy(:,2), 'g.-', 'LineWidth',2); end %# find endpoints (intersections) and show them xy = [vertcat(lines.point1);vertcat(lines.point2)]; [~,idx1] = min(xy(:,2)); [~,idx2] = max(xy(:,2)); xy = xy([idx1;idx2],:); %# intersection points plot(xy(:,1),xy(:,2), 'ro', 'LineWidth',3, 'MarkerSize',12) hold off 

screenshot

+2
source

Just looking at your lines, they are more or less straight (not concave / convex curves). In my humble opinion, there is an easier way and a more obvious way, since you know either the endpoints of the three lines. You can always get the intersection by solving x and y respectively.

http://zonalandeducation.com/mmts/intersections/intersectionOfTwoLines1/intersectionOfTwoLines1.html

gd luck

+1
source

fill in the contours std::vector<std::vector<cv::Point> > using the findContours function from the OpenCV library, then for any two circuits that do not intersect (I will explain the intersection case later): the first circuit is the sequence of two-dimensional points A1 A2 .... An and the second circuit B1, B2, .., Bm, fix some i> 0 && i <n, j> 0 && j <m and extrapolate using (A1, ... , Ai) for finding from the first end of the first contour than extrapolation (An-i, ..., An) for finding the continuation of the first contour from the second endpoint: do this o similarly for the second path (B1, ..., Bj) && (Bm-j, ..., Bm): now you can expand your paths until the borders of the image and the check intersect or not. Hope you know how to find the intersection of segments in 2D space. You should use this for all [Ai Ai + 1] and [Bj Bj + 1] i = 1, ..., n-1 && j = 1, ..., m-1

0
source

Source: https://habr.com/ru/post/892566/


All Articles