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

房东的猫 提交于 2020-01-03 08:24:09

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/32094337/how-to-calculate-the-similarity-of-two-line-drawing-images-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!