Function Repository Resource:

# ImageColorFunction

Create a color function from colors in an image

Contributed by: Mark Greenberg
 ResourceFunction["ImageColorFunction"][img] gives a color function based on the colors in img.

## Details and Options

ResourceFunction["ImageColorFunction"] works with 2D and 3D images.
ResourceFunction["ImageColorFunction"] accepts 1-channel, 3-channel and 4-channel images, outputting a function that returns RGBColor values.
ResourceFunction["ImageColorFunction"] can take the following options:
 SampleCount Automatic if a positive integer, the maximum number of key or indexed colors SampleOrder "Dominance" order of the key or indexed colors Smoothed True whether key colors are evenly spaced (True) or spaced according to dominance (False) Indexed False whether the color function is continuous (False) or discrete (True)
For SampleCountn, continuous functions will use n or the number of dominant colors in img, whichever is lowest; discrete functions will use n.
Possible values for the SampleOrder option are as follows:
 "Dominance" most dominant color (0) to least dominant (1) "Red" least red (0) to most red (1) "Green" least green (0) to most green (1) "Blue" least blue (0) to most blue (1) "Hue" least h (0) to greatest h (1) in Hue[h] "Saturation" lowest saturation (0) to highest saturation (1) "Brightness" darkest color (0) to brightest color (1)

## Examples

### Basic Examples (2)

Make a color function from an image:

 In[1]:=
 Out[1]=

Use the color function in a graphics expression:

 In[2]:=
 Out[2]=

### Options (2)

Change the number of key colors in the color function:

 In[3]:=
 Out[3]=

Change the order of key colors in the color function:

 In[4]:=
 Out[4]=

Change the spacing of key colors in the color function:

 In[5]:=
 Out[5]=

Make a discrete color function:

 In[6]:=

Use the function as an indexed color scheme:

 In[7]:=
 Out[7]=

Mark Greenberg

## Version History

• 1.0.0 – 11 November 2019