title: Image Repeating Pattern Detection With Python OpenCV
body: <p>I'm looking for a good method to detect whether an image has a repeating pattern of similar shapes or is just noise with no discernible pattern. This is best shown by looking at a couple of images:</p>
  
  <ol>
  <li>The method here would return True, and ideally identify that there are ~35 repeating shapes in the image (I wouldn't expect it necessarily to identify the cropped out shape in the lower right corner.</li>
  </ol>
  
  <p>Returns TRUE</p>
  
  <p><img src="https://i.stack.imgur.com/IxcZs.png" alt=""></p>
  
  <ol start="2">
  <li>The method here would return FALSE. While there are a lot of distinct shapes in this image, it is clear visually that there is no repeating pattern of similar shapes.</li>
  </ol>
  
  <p>Returns FALSE</p>
  
  <p><img src="https://i.stack.imgur.com/UgxJG.png" alt=""></p>
  
  <p>A few notes:</p>
  
  <ul>
  <li>The images are from patterns on a shirt. The shapes that repeat themselves aren't all exactly the same size, and may not be exactly evenly spaced. There may be anywhere from 10 shapes to several thousand shapes on a single image.</li>
  <li>I do not know in advance the size or characteristics of the shapes that repeat themselves. I'm taking these images from shirts so you can imagine there are many different types of repeating shapes.</li>
  <li>I've been using scipy.ndimage.measurements.label to identify all of the individual shapes in an image. I also use dilation to combine nearby shapes and can filter out really small shapes. </li>
  </ul>
  
  <p>I've struggled to come up with a method that is flexible enough to work with the multitude of different patterns I'm dealing with but also rigid enough to reject noise.</p>
  
  <p>Appreciate any help!</p>