title: Finding intersections of a skeletonised image in python opencv
body: <p>I have a skeletonised image (shown below).</p>
  
  <p><a href="https://i.stack.imgur.com/7sVEp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7sVEp.png" alt="Skeleton Image"></a></p>
  
  <p>I would like to get the intersections of the lines. I have tried the following method below, <code>skeleton</code> is a openCV image and the algorithm returns a list of coordinates: </p>
  
  <pre><code>def getSkeletonIntersection(skeleton):
      image = skeleton.copy();
      image = image/255;
      intersections = list();
      for y in range(1,len(image)-1):
          for x in range(1,len(image[y])-1):
              if image[y][x] == 1:
                  neighbourCount = 0;
                  neighbours = neighbourCoords(x,y);
                  for n in neighbours:
                      if (image[n[1]][n[0]] == 1):
                          neighbourCount += 1;
                  if(neighbourCount &gt; 2):
                      print(neighbourCount,x,y);
                      intersections.append((x,y));
      return intersections;
  </code></pre>
  
  <p>It finds the coordinates of white pixels where there are more than two adjacent pixels. I thought that this would only return corners but it does not - it returns many more points.</p>
  
  <p><a href="https://i.stack.imgur.com/z69zl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z69zl.png" alt="Skeleton with marked coordinates"></a></p>
  
  <p>This is the output with the points it detects marked on the image. This is because it detects some of the examples shown below that are not intersections.</p>
  
  <pre><code>0 0 0    1 1 0    0 1 1
  1 1 1    0 1 0    1 1 0
  0 0 1    0 0 1    0 0 0
  </code></pre>
  
  <p>And many more examples. Is there another method I should look at to detect intersections. All input and ideas appreciated, thanks. </p>