ColorReplaceCopy to clipboard.
✖
ColorReplace
finds regions in image whose pixel values are similar to color and replaces them with transparent pixels.
replaces all pixels with the specified replacement color.
replaces all pixels whose values are within a distance d from color.
does multiple color replacements.
Details

- ColorReplace works with arbitrary 2D and 3D images.
- ColorReplace[image,color] is equivalent to ColorReplace[image,color,0.1].
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (4)Survey of the scope of standard use cases
Use a selected color to specify the pixel values to be replaced:

https://wolfram.com/xid/0cg3xwh5u-f2vyoj

Use a marker image to specify the pixel values to be replaced:

https://wolfram.com/xid/0cg3xwh5u-ncg0yc


https://wolfram.com/xid/0cg3xwh5u-dt2m3e

Specify multicolor replacement and a default background:

https://wolfram.com/xid/0cg3xwh5u-nmwstt

Replace red pixels in a 3D image:

https://wolfram.com/xid/0cg3xwh5u-b53tpu

Applications (4)Sample problems that can be solved with this function

https://wolfram.com/xid/0cg3xwh5u-h463m


https://wolfram.com/xid/0cg3xwh5u-uqdp5h


https://wolfram.com/xid/0cg3xwh5u-mcik4c

Remove background colors with white:

https://wolfram.com/xid/0cg3xwh5u-eezupg

Shuffle colors on a logo by random color replacement:

https://wolfram.com/xid/0cg3xwh5u-vs0vnh
Find dominant colors in the image and generate random replacement:

https://wolfram.com/xid/0cg3xwh5u-f98auf


https://wolfram.com/xid/0cg3xwh5u-446czp


https://wolfram.com/xid/0cg3xwh5u-nng73r

Properties & Relations (2)Properties of the function, and connections to other functions
Replacing pixels of a grayscale image with color values will result in a color image:

https://wolfram.com/xid/0cg3xwh5u-3nroph

Use DominantColors to find the dominant green color to be replaced:

https://wolfram.com/xid/0cg3xwh5u-sdrc2s

Replace the detected shade of green with transparent:

https://wolfram.com/xid/0cg3xwh5u-b4j946

Wolfram Research (2012), ColorReplace, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorReplace.html (updated 2014).
Text
Wolfram Research (2012), ColorReplace, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorReplace.html (updated 2014).
Wolfram Research (2012), ColorReplace, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorReplace.html (updated 2014).
CMS
Wolfram Language. 2012. "ColorReplace." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/ColorReplace.html.
Wolfram Language. 2012. "ColorReplace." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/ColorReplace.html.
APA
Wolfram Language. (2012). ColorReplace. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorReplace.html
Wolfram Language. (2012). ColorReplace. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorReplace.html
BibTeX
@misc{reference.wolfram_2025_colorreplace, author="Wolfram Research", title="{ColorReplace}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/ColorReplace.html}", note=[Accessed: 30-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_colorreplace, organization={Wolfram Research}, title={ColorReplace}, year={2014}, url={https://reference.wolfram.com/language/ref/ColorReplace.html}, note=[Accessed: 30-March-2025
]}