Indeed, histograms are meant to represent the repartition of tonal values for one single channel. Color images are often 3-channels images (Red, Green, Blue in most cases).
Ghaul's method should work quite correctly. If you want to be more precise, you can extract each channel and compute its histogram:
Red1 = Im1(:, :, 1);
Green1 = Im1(:, :, 2);
Blue1 = Im1(:, :, 3);
HnBlue1 = imhist(Blue1)./numel(Blue1);
You are now able to define an evaluation fonction based on the 3 euclidean distances (1 for each channel):
FBlue = sum((HnBlue1 - HnBlue2).^2);
FRed= sum((HnRed1 - HnRed2).^2);
...
F = Alpha*FBlue + Beta*FRed + Gamma*FGreen //as an example
You can therefore put the emphasis on one color or the other in your distance definition. That could be useful if the image you want to test has a specific color.
This is an alternative to Ghaul's method, but its equivalent would be to set Alpha, Beta and Gamma as "0.2989 * R + 0.5870 * G + 0.1140 * B", as Andrey stated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…