Class Image.Colortable

Description

This object keeps colortable information, mostly for image re-coloring (quantization).

The object has color reduction, quantisation, mapping and dithering capabilities.

See also

Image, Image.Image, Image.Font, Image.GIF


Method create
Method add

Image.Colortable Image.Colortable()
Image.Colortable Image.Colortable(array(array(int)) colors)
Image.Colortable Image.Colortable(Image.Colortable colortable)
Image.Colortable Image.Colortable(Image.Image image, int number)
Image.Colortable Image.Colortable(Image.Image image, int number, array(array(int)) needed)
Image.Colortable Image.Colortable(int r, int g, int b)
Image.Colortable Image.Colortable(int r, int g, int b, object array(int)
object add(array(array(int)) colors)
object add(Image.Colortable colortable)
object add(Image.Image image, int number)
object add(Image.Image image, int number, array(array(int)) needed)
object add(int r, int g, int b)
object add(int r, int g, int b, object array(int)

Description

create initiates a colortable object. Default is that no colors are in the colortable.

add takes the same argument(s) as create, thus adding colors to the colortable.

The colortable is mostly a list of colors, or more advanced, colors and weight.

The colortable could also be a colorcube, with or without additional scales. A colorcube is the by-far fastest way to find colors.

Example:

ct=colortable(my_image,256); // the best 256 colors
ct=colortable(my_image,256,({0,0,0})); // black and the best other 255
 
ct=colortable(({({0,0,0}),({255,255,255})})); // black and white
 
ct=colortable(6,7,6); // a colortable of 252 colors
ct=colortable(7,7,5, ({0,0,0}),({255,255,255}),11);
        // a colorcube of 245 colors, and a greyscale of the rest -> 256

Parameter colors

list of colors

Parameter colortable

colortable to copy colors from.

Parameter image

source image

Parameter number

number of colors to get from the image

0 (zero) gives all colors in the image.

Default value is 256.

Parameter needed

needed colors (to optimize selection of others to these given)

this will add to the total number of colors (see argument 'number')

Parameter r
Parameter g
Parameter b

size of sides in the colorcube, must (of course) be equal or larger than 2 - if smaller, the cube is ignored (no colors). This could be used to have only scales (like a greyscale) in the output.

Parameter fromi
Parameter toi
Parameter stepi

This is to add the possibility of adding a scale of colors to the colorcube; for instance a grayscale using the arguments ({0,0,0}),({255,255,255}),17, adding a scale from black to white in 17 or more steps.

Colors already in the cube is used again to add the number of steps, if possible.

The total number of colors in the table is therefore r*b*g+step1+...+stepn.

Note

max hash size is (probably, set by a #define) 32768 entries, giving maybe half that number of colors as maximum.