ImageRecolor [image,regioncolor]
recolors pixels in image specified by region using the specified color.
ImageRecolor [image,{region1color1,…}]
recolors multiple regions.
ImageRecolor [video,…]
recolors frames of a video.
ImageRecolor
ImageRecolor [image,regioncolor]
recolors pixels in image specified by region using the specified color.
ImageRecolor [image,{region1color1,…}]
recolors multiple regions.
ImageRecolor [video,…]
recolors frames of a video.
Details and Options
- ImageRecolor can be used to replace pixels in a region with a solid color or a region consisting of shades of one color with shades of another color.
- ImageRecolor works with arbitrary 2D and 3D images.
- The region can be specified using any of the following:
-
col pixels with values close to colmaskimage grayscale or binary mask image
- Use ImageRecolor [img,col1col2] to swap two colors. »
- For video inputs, the recolor specification can be a fixed specification for all frames or a function of time (in seconds from the start).
- The following options can be given:
-
- DistanceFunction supports all the distance metrics available in ColorDistance .
- Possible settings for Method include:
-
"BrightnessPreserving" replace hue and saturation, preserving the brightness "SaturationPreserving" replace brightness and hue, preserving the saturation"HuePreserving" replace brightness and saturation, preserving the hue"Brightness" replace brightness only"Saturation" replace saturation only"Hue" replace hue only
Examples
open all close allBasic Examples (2)
Replace fully colored pixels in an image:
Replace the neighborhood of a color:
Scope (10)
Data (2)
Replace a color in an image:
Replace a color in frames of a video:
Color Specification (8)
Replace a single color:
Swap two colors:
Specify a threshold to find the matching pixels:
Use a masking image to specify the region to be replaced:
Use a marker image to specify the pixel values to be replaced:
Specify a multicolor replacement and a default background:
Specify different distances for each replacement:
Replace a color in frames of a video as a function of time:
Options (3)
DistanceFunction (1)
The default color distance is the EuclideanDistance in the Lab color space:
Use DistanceFunction to select a specific distance:
Use a custom distance function:
MaxColorDistance (1)
Use MaxColorDistance to define the maximum distance from the reference color:
Method (1)
By default, both hue and saturation of a color are replaced:
Use Method to specify a replacement target:
Applications (4)
Create a version of a product with different colors:
Try a different combination:
Recolor a map:
Change the color palette of a plot:
Use hue replacement to change a scene illumination:
Properties & Relations (7)
Color space and data type of the input image may be affected by the color replacement:
Replacing pixels of a grayscale image with color values will result in a color image:
Replacing with colors not representable in integer images will result in a type change:
Replacing a color with a transparent color will add an alpha channel to the image:
Pixels affected by a replacement will not be further processed:
Smaller values of MaxColorDistance allow finer control:
Using TwoWayRule is equivalent to two successive recolorings:
ColorReplace is used to replace a color region with an exact color:
ImageRecolor by default preserves the brightness of the replaced colors:
ImageRecolor performs the replacement in the region defined by the reference color:
ColorBalance scales every color in the image to match the reference color with the destination color:
FindMatchingColor can be used to improve reference color selection. Recolor yellow regions of an image:
Recolor using the reference yellow found in the image:
See Also
ColorReplace ColorToneMapping Colorize DominantColors ImageAdjust
Function Repository: ImageColorReplace
Related Guides
Text
Wolfram Research (2019), ImageRecolor, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageRecolor.html (updated 2021).
CMS
Wolfram Language. 2019. "ImageRecolor." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImageRecolor.html.
APA
Wolfram Language. (2019). ImageRecolor. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageRecolor.html
BibTeX
@misc{reference.wolfram_2025_imagerecolor, author="Wolfram Research", title="{ImageRecolor}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImageRecolor.html}", note=[Accessed: 17-November-2025]}
BibLaTeX
@online{reference.wolfram_2025_imagerecolor, organization={Wolfram Research}, title={ImageRecolor}, year={2021}, url={https://reference.wolfram.com/language/ref/ImageRecolor.html}, note=[Accessed: 17-November-2025]}