Pattern Based Matching

I am having trouble describing a problem area that I want to understand better, so I created the following script to help illustrate

Given the following image, how could I program something that could find all the happy faces that match the image in position 1 (name this template image) and ignore the sad face images similar to the images in positions 2 and 5.

alt text ...

I'm not looking for someone to solve this for me, I just need an insightful first step to start me, as this is uncharted territory for me.

What would it be called? What should I ask for google and stack overflows to find useful information? Does anyone have a library or code snippet that can help me get started?

In addition, I am a .NET / C # programmer by profession, so everything that happens to my native language is especially appreciated, but not a transaction violator.

Thanks in advance ... Mike

+4
source share
5 answers

The technique actually depends on the actual scenario. This is due to several names, such as content-based search, pattern matching, image description, etc.

My suggestions:

If your script looks like faces rotating at known angles with known sizes, look for simpler methods, such as correlating two images. Do it for every corner, and you got it.

If you know that the only change between images is rotation, this means that you only have happy and sad faces rotating without other distortions, you can look for methods to compare rotation invariants. Fourier theory can help you, as well as display the polar coordinates associated with correlations.

In the worst case scenario, when you have several options, you will need to learn about image descriptors and pattern matching methods. They also depend on the type of image, and there are several. If you are done with them, you will have a scheme with some libraries / code for extracting functions from images and a classifier to tell you which of them and which are not, with some certainty (for example, between feature vectors).

+1
source

See the following link to help you identify images with AForge.net Detecting some simple shapes in images

+2
source

The simplest method is likely to be pattern matching . The difference in the images of your example is quite small, so it may be difficult to distinguish, for example, images 1 and 5 in your example.

+1
source

Possible algorithm:

  • Calculate image gradient
  • For each gradient vector, calculate the direction of the gradient
  • Calculate the orientation histogram (angle in frequency) of the gradient vectors

This orientation histogram will be different from the โ€œhappyโ€ and โ€œsadโ€ emoticon.

enjoy.

+1
source

A simple algorithm for poor people just to do the job in this case can be.

  • Define the bounding box of the image and assume that the center of this is a circle.
  • Inside the circle, find two eyes like a BLOB. those. objects containing a total of 20 or pixels that correspond to a small specific rectangle.
  • Once you have set the location of the two eyes, you can determine the slope of the intersecting line between the two lines and, therefore, the orientation of the face.
  • The distance from the point in the middle of the two eyes is straight down, although the center of the circle to the mouth returns 1 out of two possible distances. those. sad or happy.

Fast and dirty and hard coding for this particular image, but it will quickly do the job.

The AForge option is probably the best generalized approach.

0
source

Source: https://habr.com/ru/post/1334160/


All Articles