ColorsNear[color]
represents a region around color.
ColorsNear[color,d]
represents a region with maximum distance d around color.
ColorsNear[color,d,dfun]
uses the specified color distance function dfun.
ColorsNear
ColorsNear[color]
represents a region around color.
ColorsNear[color,d]
represents a region with maximum distance d around color.
ColorsNear[color,d,dfun]
uses the specified color distance function dfun.
Details
- ColorsNear can be used to represent a region around a specific color.
- The distance function dfun can be any valid ColorDistance metric. Possible settings include:
-
"CIE76" Euclidean distance in LABColor "CIE94" color difference defined in LCHColor "CIE2000" CIE94 with some corrections (default) {"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 all close allBasic Examples (3)
Represent a region around red:
ColorsNear[Red]Show the region around red, green and blue:
list = {ColorsNear[RGBColor[1, 0, 0]], ColorsNear[RGBColor[0, 1, 0]], ColorsNear[RGBColor[0, 0, 1]]};
ChromaticityPlot3D[list, "LAB", PlotRange -> All]Detect image regions with colors near green:
ColorDetect[[image], ColorsNear[RGBColor[0.1842503329784037, 0.7239852610054739, 0.23646150749182665], .15]]Scope (3)
Applications (3)
Detect regions of an image with colors near red:
ColorDetect[[image], ColorsNear[RGBColor[0.8556908962771346, 0.2595055086397601, 0.1328041209333694], .15]]Detect regions using chroma differences:
ColorDetect[[image], ColorsNear[RGBColor[0.8556908962771346, 0.2595055086397601, 0.1328041209333694], .1, "DeltaH"]]Recolor regions with colors near red in an image:
ImageRecolor[[image], ColorsNear[RGBColor[0.8556908962771346, 0.2595055086397601, 0.1328041209333694], .15] -> RGBColor[0.06, 0.65, 0.8]]Use color neighborhoods for chroma keying:
i = [image];
mask = ColorDetect[i, ColorsNear[RGBColor[0.1842503329784037, 0.7239852610054739, 0.23646150749182665], .15]]Remove the green screen by setting the alpha channel:
SetAlphaChannel[i, ColorNegate[mask]]Properties & Relations (2)
Using "CIE76" distance in Lab color space; every color neighborhood is a sphere:
ChromaticityPlot3D[ColorsNear[#, .2, "CIE76"]& /@ {RGBColor[1, 0, 0], RGBColor[0, 1, 0], RGBColor[0, 0, 1], RGBColor[1, 1, 0], RGBColor[1, 0.5, 0.5], RGBColor[0.5, 0, 0.5]}, "LAB", PlotRange -> All, BoxRatios -> Automatic]The shape of the neighborhood varies for each color with other color distances:
ChromaticityPlot3D[ColorsNear[#, .1, "CIE94"]& /@ {RGBColor[1, 0, 0], RGBColor[0, 1, 0], RGBColor[0, 0, 1], RGBColor[1, 1, 0], RGBColor[1, 0.5, 0.5], RGBColor[0.5, 0, 0.5]}, "LAB", PlotRange -> All]Related Guides
History
Text
Wolfram Research (2019), ColorsNear, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorsNear.html.
CMS
Wolfram Language. 2019. "ColorsNear." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ColorsNear.html.
APA
Wolfram Language. (2019). ColorsNear. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorsNear.html
BibTeX
@misc{reference.wolfram_2026_colorsnear, author="Wolfram Research", title="{ColorsNear}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/ColorsNear.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_colorsnear, organization={Wolfram Research}, title={ColorsNear}, year={2019}, url={https://reference.wolfram.com/language/ref/ColorsNear.html}, note=[Accessed: 13-June-2026]}