palette-extract

Synopsis

(palette-extract colormap graymap)

Parameters

  • colormap: A RGB colormap
  • graymap: A graymap with the same dimensions as the colormap

Description

This procedure extracts the color palette from the colormap by associating an RGB value to each occurring gray value. Usually, the graymap is derived from the colormap in some way (see the example below).

Side Effects

Return Value

The extracted palette is returned and is ready for interpolation or any other processing.

Example

> (define c (colormap-readjpg "input.jpg"))
c
> (define g (colormap->graymap c))
g
> (graymap-equalize! g)
#<graymap(16) orow:-1 ocol:-1 xres:-1 yres:-1 w:880 h:587>
> (graymap-normalize! g)
#<graymap(16) orow:-1 ocol:-1 xres:-1 yres:-1 w:880 h:587>
> (define p (palette-extract c g))
p
> p
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 w:65536 h:1>
> (palette-interpolate! p)
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 w:65536 h:1>
>