Ask Your Question

Detecting pattern in an image

asked 2017-12-13 05:46:00 -0500

Antarus gravatar image

updated 2017-12-13 05:46:58 -0500

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. Pattern

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-13 07:16:34 -0500

pi-null-mezon gravatar image

updated 2017-12-13 07:49:27 -0500

You can use copyMakeBorder(...) function to enlarge your image with borderType=BORDER_WRAP option. After that you can process only central part of the new image and it seems that your task should be solved

edit flag offensive delete link more


Thanks a lot! That really helped me and as I'm a beginner in the computer vision development, I had no idea of such a function. It does the job.

Antarus gravatar imageAntarus ( 2017-12-14 05:30:20 -0500 )edit

Question Tools

1 follower


Asked: 2017-12-13 05:46:00 -0500

Seen: 1,843 times

Last updated: Dec 13 '17