I want to detect a repeating pattern in an image. So far I detected the contours for each individual object, separated each of the objects by their contours, ending up with a vector of objects of type A, a vector of objects of type B and so on.
Next I tried getting the pattern by extracting the object with the biggest area, putting it in a rectangle, next selecting one object of each kind which is positioned the closest to the current rectangle. After finding a new object, the rectangle would be resized, covering the new object too. In the end, after going through every type of objects and selecting the closest one to the current rectangle from each, I would end up with a rectangle inside which I would have the pattern found in the image.
Well, the problem with the method described is that in a pattern image we can have parts of an object at the sides of the image, and I would end up detecting them as a whole new type of object.
As the method described would try to get one of each type of objects inside a rectangle, I end up with a rectangle with the size of the image.
My questions here is, how could I detect a part of an object A, therefore not detecting it as a new type of an object? Also, could the hierarchy returned by the findContours be used in detecting the pattern from an image?
In case anyone has any idea of how I could detect a pattern in an image or is aware of some research paper related to the subject, I would appreciate if you would share it with me.