Image Processing Khorosware: Color Table

# Color Table

## Autocoloring Procedures and Colormap Options

Basically we want to "play" (alter) the colormap of an image. The two methods are:

- autocoloring procedure: where the existing colormap is replaced with a predefined colormap.
- colormap operation: where existing values in a colormap are modified according to a predefined algorithm.

### Autocoloring Procedures

Two mapping schemes.

- positional mapping: map values at any position in the map are generated only as a function of that position (index). There is no dependency on the properties of the pixel value, only on physical layout.
- data dependent: the map values are generated as a function of the pixel value.

Data model for map operations

In this experiment we wish to convert a black and white image like

into a colored one like this

The idea is to first label the image, such that a unique value is assigned to each pixel belonging to a connected region. Normally, the labeling process assigns region numbers in a ascending order so that the maximum number corresponds to the the number of connected region.

Labeled image: grey

From the statistics of the labeled image we note that there are 24 regions: 0 is the background and 1 to 23 are the other connected regions. Use the mouse to identify the pixel values corresponding to the three small circles of the logo. These values are: 1, 10 and 16.

A color table can be built to assign pixel values 0 the color white, pixel values 1, 10 and 16 the color red, and the rest to black.

The color table using the RGB model is (the index column is not needed):

    value R   G   B        color
    -----------------------------
    0     255 255 255      white
    1     255 0   0        red
    2     0   0   0        black
    3     0   0   0        black
    ...
    9     0   0 0 0        black
    10    255 0   0        red
    11    0   0   0        black
    ...
    15    0   0   0        black
    16    255 0   0        red
    17    0   0   0        black
    ...
    23    0   0   0        black

The color table can be visualized below. There are 24 colors in the table. Counting from the left corner we see that index zero corresponds to the color white, index values 1, 10, 16 to red and the rest to black.

Displaying a color table

Applying this color table to the labeled image yields

-- color table -->

- Building a visual program (workspace) in cantata
- Execute the visual program logo-color.wk