ColorDistance
ColorDistance[c1,c2]
gives the approximate perceptual distance between color directives c1 and c2.
ColorDistance[list,c]
gives color distances between elements of list and c.
ColorDistance[list1,list2]
gives color distances between corresponding elements of list1 and list2.
ColorDistance[image,c]
gives an image whose pixel values are color distance between pixels in image and the color c.
ColorDistance[image1,image2]
yields an image giving the pixelwise color distance between image1 and image2.
Details and Options
- Color distance, also known as color difference, gives a measure of visual, perceptual color differences. Perceptually similar colors have smaller distance.
- ColorDistance computes the distance between two colors as the Euclidean distance between the two color vectors in the LABColor space.
- In the computation of the color distance, the alpha channel is ignored.
- ColorDistance works with arbitrary 2D and 3D images.
- With ColorDistance[image,…], color distances are returned as an image of a real type with the same dimensions as image.
- With ColorDistance[image1,image2], image1 and image2 are center aligned, and an image of color distances for the overlapping pixels is returned.
- ColorDistance supports a DistanceFunction option. The following settings are available:
-
"CIE76" Euclidean distance in LABColor (default) "CIE94" color difference defined in LCHColor "CIE2000" CIE94 with some corrections {"CMC",{l,c}} Color Measurement Committee metric with lightness l and chroma c "DeltaL" luminance difference in LCHColor "DeltaC" chroma difference in LCHColor "DeltaH" hue-based difference in LCHColor f function f that is given two lists of Lab values - With the "CMC" metric, commonly used parameters are for perceptibility and for acceptability. If not specified, is used.
Examples
open allclose allBasic Examples (2)
Scope (5)
Options (8)
DistanceFunction (8)
By default, "CIE76" (also spelled ΔEa*b*) is used:
This corresponds to EuclideanDistance for LABColor components:
Visualize the "CIE76" color distance in the "LAB" space:
Use "CIE94" measure for computing the color distance (also spelled ΔE94):
Note that this measure is not symmetric:
Use "CIE2000" measure for computing the color distance (also spelled "CIEDE2000" or ΔE00):
Note that this measure is symmetric:
Distance between L* channels visualized in the "LAB" space:
Distance between two color chromas, each being computed as Norm[{}]:
Use a custom distance function that is only based on the luminance:
Applications (6)
Highlight details in an image using a selective desaturation:
Segment components of specific colors in an image:
Detect motion by comparing two images:
This image has a strong red color cast:
The default distance considers differences in hue, luminance, and chroma:
Use DistanceFunction"DeltaH" to measure only the differences in hue:
Cluster a list of colors based on their distance:
Sort a list of colors using their perceptual distance from a reference color:
Properties & Relations (8)
ColorDistance is equivalent to EuclideanDistance of the color in the LABColor space:
The distance between a color and itself is always zero:
The distance between a color represented in two color spaces is zero:
Notice that this distance may be nonzero if the color is not available in the new color space:
The alpha channel is not used when computing the distance:
For RGB colors, the typical range of distances for each method is as follows:
Define a sample set using the boundary of the RGB cube:
Compute all pairwise distances between the sample colors:
Not all the color distances are metrics in a mathematical sense:
"CIE94" and "CMC" are not symmetric:
"CIE94", "CIE2000", "CMC", and "DeltaH" do not always satisfy the triangle inequality:
Simulated frequencies of satisfying the triangular inequality depend on the specified distance:
"CIE2000" is one of the latest standards, introducing many improvements over the simple Lab distance. It is perceptually more accurate compared to "CIE76" and "CIE94":
Show constant-distance curves on the plane for a fixed lightness, :
However, "CIE2000" is computationally more expensive compared to the older metrics:
ImageDistance by default computes the Euclidean distance between two images in the RGB space:
ColorDistance by default computes the Euclidean distance between two pixels in the LAB space:
ColorDistance returns the distance between the central regions of images with different dimensions:
The distance between two images may be identically zero if their overlapping regions coincide:
Text
Wolfram Research (2014), ColorDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorDistance.html (updated 2015).
CMS
Wolfram Language. 2014. "ColorDistance." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/ColorDistance.html.
APA
Wolfram Language. (2014). ColorDistance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorDistance.html