WOLFRAM

Copy to clipboard.
ColorReplace[image,color]

finds regions in image whose pixel values are similar to color and replaces them with transparent pixels.

Copy to clipboard.
ColorReplace[image,colorreplacement]

replaces all pixels with the specified replacement color.

Copy to clipboard.
ColorReplace[image,colorreplacement,d]

replaces all pixels whose values are within a distance d from color.

Copy to clipboard.
ColorReplace[image,{color1replacement1,},{d1,}]

does multiple color replacements.

Details

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Replace a background with transparency:

Out[1]=1

Replace black pixels in an image:

Out[1]=1

Scope  (4)Survey of the scope of standard use cases

Use a selected color to specify the pixel values to be replaced:

Out[7]=7

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

Out[1]=1

Specify a distance value:

Out[2]=2

Specify multicolor replacement and a default background:

Out[1]=1

Replace red pixels in a 3D image:

Out[1]=1

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

Green screen replacement:

Out[2]=2

Change the plot color:

Out[1]=1

Also remove the axes:

Out[2]=2

Remove background colors with white:

Out[1]=1

Shuffle colors on a logo by random color replacement:

Find dominant colors in the image and generate random replacement:

Out[2]=2
Out[3]=3

Replace colors:

Out[4]=4

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:

Out[4]=4

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

Out[1]=1

Replace the detected shade of green with transparent:

Out[2]=2
Wolfram Research (2012), ColorReplace, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorReplace.html (updated 2014).
Copy to clipboard.
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).

Copy to clipboard.
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.

Copy to clipboard.
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

Copy to clipboard.
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 ]}

Copy to clipboard.
@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 ]}

Copy to clipboard.
@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 ]}