How can I compare two RGB colors to see if they look the same (to human eyes). And I'd like to be able to control the amount of similarity.
Say for example 15. What is the best way to compare the colors to have more colors in the range.
I have two idea in my mind but I don't know if they are the best options:
% (colorN(1) to colorN(3) are the RGB value of the color)
% Method 1:
if abs(double(color1(1)) - double(color2(1))) < 15 ... && abs(double(color1(2)) - double(color2(2))) < 15 ... && abs(double(color1(3)) - double(color2(3))) < 15 % The colors are similar
end % Method 2
if sum(abs(double(color1(1)) - double(color2(1))), ... abs(double(color1(2)) - double(color2(2))), ... abs(double(color1(3)) - double(color2(3)))) < 15 % The colors are similar end % Maybe method 3 which is a combination of the two.
I've tried these a little bit by myself but I wasn't happy with the results. Anyone knows a better way to compare? Does Matlab have a function for that?
Best Answer