ImageRecolor

ImageRecolor[image,regioncolor]

recolors pixels in image specified by region using the specified color.

ImageRecolor[image,{region1color1,}]

recolors multiple regions.

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:
  • colpixels with values close to col
    maskimagegrayscale or binary mask image
    ColorsNear[col,]pixels defined by a specific ColorsNear object
    ImageMarker[markerimage]marker image used to compute the color to be replaced
  • Use ImageRecolor[img,col1col2] to swap two colors.48228161
  • The following options can be given:
  • DistanceFunctionAutomaticcolor distance metric to use
    MaxColorDistance0.1maximum distance from the reference color
    Method"BrightnessPreserving"method to use
  • 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 all

Basic Examples  (2)

Replace fully colored pixels in an image:

In[2]:=
Click for copyable input
Out[2]=

Replace the neighborhood of a color:

In[1]:=
Click for copyable input
Out[1]=

Scope  (7)

Options  (3)

Applications  (4)

Properties & Relations  (7)

Introduced in 2019
(12.0)