How to calculate the similarity of two line drawing images in swift

1.5k views Asked by At

We need to compare two hand drawn images..these images are drawn on the sprite kit.we need to see whether these pictures are roughly match or not. For Example, if someone draws a smile pic, we need to check whether the redrawing smile pic is looks like the first drawn smile pic or not.we need to know whether the two images look alike or not...and to calculate the accuracy percentage of how similar they are..Please suggest some solutions.Thanks in advance.

2

There are 2 answers

0
Tommie C. On

You could try draw each of the paths into bitmaps and comparing them. Here are a few suggestions for doing the comparison. If nothing else this will put you onto the correct track for resolution. The following project can give you a head start but needs to be translated to objc or Swift. This answer on code review may also prove useful.

One suggestion that seems intriguing is trying to use kCGBlendModeDestinationOver to draw the bitmaps as a trace over each other and comparing the results.

0
Jean-Baptiste Yunès On

There exists a mathematical tool for this, that is called Hausdorff distance.

Entry for Hausdorff distance in Wikipedia may help you to understand how it works. I can also suggest you a scientific paper about comparing images with this Comparing images with Hausdorff distance.

You may also find using Euclidian distance for this, have a look at Euclidian distance of Images.