title: Hit or miss morphology in python to find structures in images does not give the required results
body: <p>I am using the morphology package to create a skeletonized version of the image we are using. We are able to detect the termini in the skeletonized version, but would also like to be able to detect the points where structure makes new branches. We started with trying to detect them with 3 different matrices, named h1,h2,h3. For now we don't have the miss matrix filled for filtering, that is something we will try to add later. We are using 5x5 matrices for ease of editing if we want to try filtering later.</p>
  
  <p>The problem is that even though the pattern in matrix h1 and h2 are present in the skeletonized version, it is not able to detect them. Matrix h3 does work.
  I can't seem to find why this happens.</p>
  
  <pre><code>def branches(img_pruned,cropped_image):
  img = img_pruned
  nbranches = 0
  branches = cropped_image
  
  h1 = [
      [0,0,0,0,0],
      [0,0,0,1,0],
      [0,1,1,0,0],
      [0,0,1,0,0],
      [0,0,0,0,0]]
  h2 = [
      [0,0,0,0,0],
      [0,1,0,1,0],
      [0,0,1,0,0],
      [0,0,1,0,0],
      [0,0,0,0,0]]
  h3 = [
      [0,0,0,0,0],
      [0,1,1,1,0],
      [0,0,1,0,0],
      [0,0,0,0,0],
      [0,0,0,0,0]]
  m1 = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]
  
  hitlist = []
  misslist = []
  
  for i in range(4):
      hitlist.append(np.rot90(h1, i))
      hitlist.append(np.rot90(h2, i))
      hitlist.append(np.rot90(h3, i))
  for t in range(12):
      misslist.append(m1)
  
  for hit,miss in zip(hitlist,misslist):
      branchimg = m.binary_hit_or_miss(img,hit,miss)
  
  for y in range(len(branchimg)):
      for x in range(len(branchimg[y])):
          if branchimg[y][x]:
              nbranches +=1
              branches[y][x] = (0,0,255)
  
  print nbranches
  return branches
  </code></pre>
  
  <p>The original image we took.</p>
  
  <p>image:<img src="https://i.stack.imgur.com/vWIYh.jpg" alt=""></p>
  
  <p>The skeletonized photo, we also used pruning to make the termini (ending points of the branches) smoother.</p>
  
  <p><img src="https://i.stack.imgur.com/kXzv7.jpg" alt=""></p>