ColorMapping

Map a label image to 8-bits RGB using look-up tables.

Description

Map a label image to a 8-bits RGB image (both ways) using different methods:

  • Custom: use a custom look-up table. The look-up table is loaded from a text file where each line describes an entry. The typical use of this method is to colorise a classification map.

  • Continuous: Map a range of values in a scalar input image to a colored image using continuous look-up table, in order to enhance image interpretation. Several look-up tables can been chosen with different color ranges.

  • Optimal: Compute an optimal look-up table. When processing a segmentation label image (label to color), the color difference between adjacent segmented regions is maximized. When processing an unknown color image (color to label), all the present colors are mapped to a continuous label list.

  • Support image: Use a color support image to associate an average color to each region.

Parameters

Input Image -in image Mandatory
Input image filename

Output Image -out image [dtype] Mandatory
Output image filename

Operation -op [labeltocolor|colortolabel] Default value: labeltocolor
Selection of the operation to execute (default is: label to color).

  • Label to color

  • Color to label

Color to label options

Not Found Label -op.colortolabel.notfound int Default value: 404
Label to use for unknown colors.


Color mapping method -method [custom|continuous|optimal|image] Default value: custom
Selection of color mapping methods and their parameters.

  • Color mapping with custom labeled look-up table
    Apply a user-defined look-up table to a labeled image. Look-up table is loaded from a text file.

  • Color mapping with continuous look-up table
    Apply a continuous look-up table to a range of input values.

  • Compute an optimized look-up table
    [label to color] Compute an optimal look-up table such that neighboring labels in a segmentation are mapped to highly contrasted colors. [color to label] Searching all the colors present in the image to compute a continuous label list

  • Color mapping with look-up table calculated on support image

Color mapping with custom labeled look-up table options

Look-up table file -method.custom.lut filename [dtype] Mandatory
An ASCII file containing the look-up table with one color per line (for instance the line ‘1 255 0 0’ means that all pixels with label 1 will be replaced by RGB color 255 0 0) Lines beginning with a # are ignored

Color mapping with continuous look-up table options

Look-up tables -method.continuous.lut [red|green|blue|grey|hot|cool|spring|summer|autumn|winter|copper|jet|hsv|overunder|relief] Default value: red
Available look-up tables.

  • Red

  • Green

  • Blue

  • Grey

  • Hot

  • Cool

  • Spring

  • Summer

  • Autumn

  • Winter

  • Copper

  • Jet

  • HSV

  • OverUnder

  • Relief

Mapping range lower value -method.continuous.min float Default value: 0
Set the lower input value of the mapping range.

Mapping range higher value -method.continuous.max float Default value: 255
Set the higher input value of the mapping range.

Compute an optimized look-up table options

Background label -method.optimal.background int Default value: 0
Value of the background label

Color mapping with look-up table calculated on support image options

Support Image -method.image.in image Mandatory
Support image filename. For each label, the LUT is calculated from the mean pixel value in the support image, over the corresponding labeled areas. First of all, the support image is normalized with extrema rejection

NoData value -method.image.nodatavalue float Default value: 0
NoData value for each channel of the support image, which will not be handled in the LUT estimation. If NOT checked, ALL the pixel values of the support image will be handled in the LUT estimation.

lower quantile -method.image.low int Default value: 2
lower quantile for image normalization

upper quantile -method.image.up int Default value: 2
upper quantile for image normalization


Available RAM (MB) -ram int Default value: 256
Available memory for processing (in MB).

Examples

From the command-line:

otbcli_ColorMapping -in ROI_QB_MUL_1_SVN_CLASS_MULTI.png -method custom -method.custom.lut ROI_QB_MUL_1_SVN_CLASS_MULTI_PNG_ColorTable.txt -out Colorized_ROI_QB_MUL_1_SVN_CLASS_MULTI.tif

From Python:

import otbApplication

app = otbApplication.Registry.CreateApplication("ColorMapping")

app.SetParameterString("in", "ROI_QB_MUL_1_SVN_CLASS_MULTI.png")
app.SetParameterString("method","custom")
app.SetParameterString("method.custom.lut", "ROI_QB_MUL_1_SVN_CLASS_MULTI_PNG_ColorTable.txt")
app.SetParameterString("out", "Colorized_ROI_QB_MUL_1_SVN_CLASS_MULTI.tif")

app.ExecuteAndWriteOutput()

Limitations

The segmentation optimal method does not support streaming, and thus large images. The operation color to label is not implemented for the methods continuous LUT and support image LUT.

ColorMapping using support image is not threaded.

See also

ImageSVMClassifier