Using Objective-C, is there any way to compare two images and get a % difference value returned?

后端 未结 4 682
别那么骄傲
别那么骄傲 2021-01-15 11:31

Using Objective-C, is there any way to compare two images and get a % difference value returned?

For example, one image will have and X in it. Another image will ha

4条回答
  •  走了就别回头了
    2021-01-15 11:58

    The API's have nothing like this available.

    If you want to do this you'll have to roll your own or use an external library.

    I would suggest finding an external library as this is not a trivial task.

    For example, You have two images with an x the same font and color. Are the images the same size? If not, are they considered 100% different? If you resize the images to match, the difference is going to be much higher than it would be otherwise.

    Or, let's say that you have two images with an x the same font and image size, but the colors are different. How would you weight that as a percent? Totally different or partially different? If you say that color is only partially different then how would you ever get a 100% difference?

    Regardless, the basic way to do this (this I can see, I am sure someone much smarter will have a better idea) is to go pixel by pixel and compare the color data (HSV might be a good choice for this). Weight the components and calculate your difference.

提交回复
热议问题