Color difference

The difference or distance between two colors is a metric of interest in color science. It allows quantified examination of a notion that formerly could only be described with adjectives. Quantification of these properties is of great importance to those whose work is color-critical. Common definitions make use of the Euclidean distance in a device independentcolor space.

Metric for difference between two colors

. . . Color difference . . .

As most definitions of color difference are distances within a color space, the standard means of determining distances is the Euclidean distance. If one presently has an RGB (Red, Green, Blue) tuple and wishes to find the color difference, computationally one of the easiest is to consider R, G, B linear dimensions defining the color space.

distance=(R2R1)2+(G2G1)2+(B2B1)2{displaystyle mathrm {distance} ={sqrt {(R_{2}-R_{1})^{2}+(G_{2}-G_{1})^{2}+(B_{2}-B_{1})^{2}}}}

When the result should be computationally simple as well, it is often acceptable to remove the square root and simply use:

distance2=(R2R1)2+(G2G1)2+(B2B1)2{displaystyle mathrm {distance} ^{2}={(R_{2}-R_{1})^{2}+(G_{2}-G_{1})^{2}+(B_{2}-B_{1})^{2}}}

This will work in cases when a single color is to be compared to a single color and the need is to simply know whether a distance is greater. If these squared color distances are summed, such a metric effectively becomes the variance of the color distances.

There have been many attempts to weigh RGB values to better fit human perception, where the components are commonly weighted (red 30%, green 59%, and blue 11%), however these are demonstrably worse at color determinations and are properly the contributions to the brightness of these colors, rather than to the degree to which human vision has less tolerance for these colors. The closer approximations would be more properly (for non-linear sRGB, using a color range of 0255):[1]

{2×ΔR2+4×ΔG2+3×ΔB2R¯128,3×ΔR2+4×ΔG2+2×ΔB2otherwise,{displaystyle {begin{cases}{sqrt {2times Delta R^{2}+4times Delta G^{2}+3times Delta B^{2}}}&{bar {R}}

where:

ΔR=R1R2ΔG=G1G2ΔB=B1B2R¯=R1+R22{displaystyle {begin{aligned}Delta R&=R_{1}-R_{2}\Delta G&=G_{1}-G_{2}\Delta B&=B_{1}-B_{2}\{bar {R}}&={{R_{1}+R_{2}} over 2}\end{aligned}}}

One of the better low-cost approximations, sometimes called “redmean”, combines the two cases smoothly:[1]

r¯=R1+R22,ΔC=(2+r¯256)×ΔR2+4×ΔG2+(2+255r¯256)×ΔB2.{displaystyle {begin{aligned}{bar {r}}&={{R_{1}+R_{2}} over 2},\Delta C&={sqrt {left({2+{{bar {r}} over {256}}}right)times Delta R^{2}+4times Delta G^{2}+left({2+{{255-{bar {r}}} over {256}}}right)times Delta B^{2}}}.end{aligned}}}

There are a number of color distance formulae that attempt to use color spaces like HSV with the hue as a circle, placing the various colors within a three dimensional space of either a cylinder or cone, but most of these are just modifications of RGB; without accounting for differences in human color perception they will tend to be on par with a simple Euclidean metric.

. . . Color difference . . .

This article is issued from web site Wikipedia. The original article may be a bit shortened or modified. Some links may have been modified. The text is licensed under “Creative Commons – Attribution – Sharealike” [1] and some of the text can also be licensed under the terms of the “GNU Free Documentation License” [2]. Additional terms may apply for the media files. By using this site, you agree to our Legal pages . Web links: [1] [2]

. . . Color difference . . .