开发者

I need to diff two images to see what color(s) are different. Any medium level algorithms?

开发者 https://www.devze.com 2023-01-21 07:37 出处:网络
If I have two images which ar开发者_运维问答e both the left side view of a the same shoe in different styles, how can I determine by which color(s) they differ?Perhaps it\'s a shoe in two styles, one

If I have two images which ar开发者_运维问答e both the left side view of a the same shoe in different styles, how can I determine by which color(s) they differ? Perhaps it's a shoe in two styles, one style has pink laces and a white side, the other has white laces and a yellow side. I want:

Image One Colors: C1=Pink, C2=White

Image Two Colors: C1=White, C2=Yellow

No super high level algorithms, but I don't need actual implemented code either. Perhaps just loops, data structures, conditions..

The actual shoe part of the image will be on a white background. These will be photographs similar to what you'd see on endless.com or zappos.com so they're very similar, but require some tolerance.


Since it sounds like you only want to tell what colours they differ by (without regard to shape etc.) and that you expect the shapes will be highly similar (though not identical), I would:

  1. Compute colour histograms for each image (you may need 3 histograms each for R, G, B)
  2. Subtract them (z = abs(x - y) for each colour)
  3. Identify peaks in the resulting histogram(s)

When a significant area is coloured differently in each image, this will give you two high peaks in the final histogram(s). (Drop the abs() if you need to tell which is which.)

[EDIT] As jilles de wit suggests, it's better to look at frequencies of (R, G, B) triples instead of individual colours (i.e. for each image create one big histogram of size 256*256*256 instead of 3 size-256 histograms). But in this case the histogram vector is huge and likely to be mainly filled with zeros, so it is a good idea to quantise the intensities down from 256 to say 16 levels, giving a more manageable 16*16*16 vector.


you should be able to use something along the lines of the 'diff' command in bash, to compare the contents of the two files directly. Then, you can analyze that data, process it into colors (using a hex chart to aid you) and print out the different colors. To get coherent results from diff, I recommend cating it into a text file, and then processing the text file. Something like 'diff file1.jpeg file2.jpeg > differences.txt'

This can be done from a C program quite easily. This is, however, a solution for a unix based system, I don't know if Windows has the operation available.

0

精彩评论

暂无评论...
验证码 换一张
取 消