title: How to detect bullet holes on a shooting target
body: <p>I'm currently working on my first assignment in image processing (using OpenCV in Python, but I'm open to any libraries and languages). My assignment is to calculate a precise score (to tenths of point) of one to several shooting holes in an image uploaded by a user. The issue is that the image uploaded by the user can be taken on different backgrounds (although it will never match the rest of the target mean colors). Due to this, I have ruled out most of the solutions found on the internet and most of the solutions I could come up with.</p>
  
  <h1><strong><em>Summary of my problem</em></strong></h1>
  
  <h2>Bullet holes identification:</h2>
  
  <ul>
  <li>bullet holes can be on different backgrounds</li>
  <li>bullet holes can overlap</li>
  <li>single bullet holes will always be of similar size (there is only one type of caliber used on all of the calculated shooting targets)
  
  <ul>
  <li>I'm able to calculate a very precise radius of the shooting hole</li>
  </ul></li>
  </ul>
  
  <h2>Shooting targets:</h2>
  
  <ul>
  <li>there are two types of shooting targets that my app is going to calculate (images provided below)</li>
  <li>photos of the shooting targets can be taken in different lighting conditions</li>
  </ul>
  
  <h3>Shooting target 1 example:</h3>
  
  <p><a href="https://i.stack.imgur.com/8EeO7.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/8EeO7.jpg" alt="Shooting target 1 example"></a></p>
  
  <h3>Shooting target 2 example:</h3>
  
  <p><a href="https://i.stack.imgur.com/LsdeO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/LsdeO.jpg" alt="enter image description here"></a></p>
  
  <h3>Shooting target examples to find bullet holes in:</h3>
  
  <ul>
  <li><a href="https://imgur.com/QZCt7kr" rel="noreferrer">shooting target example 1</a></li>
  <li><a href="https://imgur.com/NDtTSvX" rel="noreferrer">shooting target example 2</a></li>
  <li><a href="https://imgur.com/yHoyVCo" rel="noreferrer">shooting target example 3</a></li>
  <li><a href="https://imgur.com/lN7QfX6" rel="noreferrer">shooting target example 4</a></li>
  <li><a href="https://imgur.com/o8xx1hl" rel="noreferrer">shooting target example 5</a></li>
  </ul>
  
  <h2>What I tried so far:</h2>
  
  <ol>
  <li><strong>Color segmentation</strong>
  
  <ul>
  <li>due to the reasons mentioned above</li>
  </ul></li>
  <li><strong>Difference matching</strong>
  
  <ul>
  <li>to be able to actually compare the target images (empty and fired on), I have written an algorithm that crops the target by its outer largest circle (its radius + bullet size in pixels)</li>
  <li>after that, I have probably tried all of the ways of images comparison found on the internet</li>
  <li>for example: brute force matching, histogram comparisons, feature matching and many more</li>
  <li>I failed here mostly because the colors on both compared images were a bit different and also because one of the images was sometimes taken in a slight angle and therefore the circles weren't overlapping and they were calculated as differences</li>
  </ul></li>
  <li><strong>Hough circles algorithm</strong>
  
  <ul>
  <li>since I know the radius (in pixels) of the shots on the target I thought I could simply detect them using this algorithm</li>
  <li>after several hours/days of playing with parameters of HoughCircles function, I figured it would never work on all of the uploaded images without changing the parameters based on the uploaded image</li>
  </ul></li>
  <li><strong>Edge detection and finding contours of the bullet holes</strong>
  
  <ul>
  <li>I have tried two edge detection methods (Canny and Sobel) while playing with image smoothening  algorithms (like blurring, bilateral filtering, metamorphization, etc..)</li>
  <li>after that, I have tried to find all of the contours in the edge detected image and filter out the circles of the target with a similar center point</li>
  <li>this seemed like the solution at first, but on several test images it wouldn't work properly :/</li>
  </ul></li>
  </ol>
  
  <p><strong>At this point, I have ran out of ideas and therefore came here for any kind of advice or an idea that would push me further. Is it possible that there simply isn't a solution to such complicated shooting target recognition or am I just too inexperienced to come up with it?</strong></p>
  
  <p>Thank you in advance for any help.</p>
  
  <p>Edit: I know I could simply put a single color paper behind the shooting target and find the bullets that way. This is not how I want the app to work thought and therefore it's not a valid solution to my problem.</p>