简体   繁体   中英

Pattern recognition in an image using python?

How can I use Python to find similar simple patterns in a black and white image? For example: find all figures with a horizontal pattern and all figures with vertical lines and mark them as separate groups. I guess I'll end up using the OpenCV library but haven´t quite found the way.

To make myself clear, I include images of what I would expect the program to do.

原图

处理过的图像

I assume that the patterns you are looking for are already known.
Template Matching should then do the trick for you:

Template Matching is a method for searching and finding the location of a template image in a larger image.

Things will get more complicated, if the patterns your are looking for are scaled or rotated in the bigger image, but from the example you provided this shouldn't be the case

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM