title: Detecting intersecting lines after a hough transform
body: <p>Using Hough transform in Matlab,detected some lines. Using the end points of these lines I have plotted them. I cant understand how I can find intersecting lines when I have all the variables. </p>
  
  <pre><code>Line7
  Point1 [50,66]
  Point2 [11,106]
  theta,rho [45,81]
  
  
  Line9
  Point1 [19,83]
  Point2 [53,79]
  theta,rho [82,84]
  </code></pre>
  
  <p>Since the parametric equations are as follows</p>
  
  <pre><code>  rho = xCos(theta) + ySin(theta)
  </code></pre>
  
  <p>I am unsure how to solve this. With all this information there must be a quick way of finding if the lines intersect, if so, the points as well.</p>
  
  <p>Any guidance much appreciated.</p>
  
  <pre><code>function FindHoughLines(I,filename)
  [H,T,R] = hough(I);
  rotI = imrotate(I,0,'crop');
  imshow(H,[],'XData',T,'YData',R,...
              'InitialMagnification','fit');
  xlabel('\theta'), ylabel('\rho');
  axis on, axis normal, hold on;
  P  = houghpeaks(H,10,'threshold',ceil(0.1*max(H(:))));
  x = T(P(:,2)); y = R(P(:,1));
   plot(x,y,'s','color','white');
  % Find lines and plot them
  lines = houghlines(I,T,R,P,'FillGap',5,'MinLength',7);
   figure, imshow(rotI), hold on
  max_len = 0;
  for k = 1:length(lines)
      if(isField(lines,'point1') ~= 0)               
     xy = [lines(k).point1; lines(k).point2];
      plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
  
     % Plot beginnings and ends of lines
     plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
     plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
     text(xy(1,1),xy(1,2),[ num2str(k)],'HorizontalAlignment','center','BackgroundColor',[.7 .9 .7]);
     % Determine the endpoints of the longest line segment
     len = norm(lines(k).point1 - lines(k).point2);
     if ( len &gt; max_len)
        max_len = len;
        xy_long = xy;
     end
      end
  end
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/3DEFP.png" alt="Lines"></p>