I'm working on an image comparsion algorithm and need a bit help. I do not want find identical images, but images with similar colors and color-temperatures. My first try was to use hash-values, second try was to use histograms. But both methods didn't produce satisfactory results.
Now I simply want to count colors in the images:
- I bring the images to same size (let's say 100x100px).
- I reduce the colors to 8 or only 4 bits per pixel.
Afterwards I calculate a dictionary with color-values per image:
// sample output:
// Dictionary<Color, int> imageColors;
// imageColors[(0, 32, 128)] = 67 // 67 pixels have this color
// imageColors[(0, 64, 128)] = 198 // ...
// imageColors[(96, 0, 160)] = 74 // ...
// and so on...
That work's well and fast. I'm using LockBits und unsafe pointer. For better understanding here the simple method to reduce colors:
static byte ReduceColorValue(byte colorChannelValue, byte factor = 32)
{
return (byte)(colorChannelValue / factor * factor);
}
I hope that's understandable.
And now the question: How can I compare those dictionaries with color-values/count? I have to calculate a comparable value that says how equal 2 pictures are.