4.1.1 Color Mapping

Maps an input label image to 8-bits RGB using look-up tables.

Detailed description

This application allows one to map a label image to a 8-bits RGB image (in both ways) using different methods.
-The custom method allows one to 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.
-The continuous method allows mapping 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.
-The optimal method computes 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.
- The support image method uses a color support image to associate an average color to each region.

Parameters

This section describes in details the parameters available for this application. Table 4.2, page 414 presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is ColorMapping.





Parameter key

Parameter type

Parameter description




in

Input image

Input Image

out

Output image

Output Image

ram

Int

Available RAM (Mb)

op

Choices

Operation

op labeltocolor

Choice

Label to color

op colortolabel

Choice

Color to label

op.colortolabel.notfound

Int

Not Found Label

method

Choices

Color mapping method

method custom

Choice

Color mapping with custom labeled look-up table

method continuous

Choice

Color mapping with continuous look-up table

method optimal

Choice

Compute an optimized look-up table

method image

Choice

Color mapping with look-up table calculated on support image

method.custom.lut

Input File name

Look-up table file

method.continuous.lut

Choices

Look-up tables

method.continuous.lut red

Choice

Red

method.continuous.lut green

Choice

Green

method.continuous.lut blue

Choice

Blue

method.continuous.lut grey

Choice

Grey

method.continuous.lut hot

Choice

Hot

method.continuous.lut cool

Choice

Cool

method.continuous.lut spring

Choice

Spring

method.continuous.lut summer

Choice

Summer

method.continuous.lut autumn

Choice

Autumn

method.continuous.lut winter

Choice

Winter

method.continuous.lut copper

Choice

Copper

method.continuous.lut jet

Choice

Jet

method.continuous.lut hsv

Choice

HSV

method.continuous.lut overunder

Choice

OverUnder

method.continuous.lut relief

Choice

Relief

method.continuous.min

Float

Mapping range lower value

method.continuous.max

Float

Mapping range higher value

method.optimal.background

Int

Background label

method.image.in

Input image

Support Image

method.image.nodatavalue

Float

NoData value

method.image.low

Int

lower quantile

method.image.up

Int

upper quantile

inxml

XML input parameters file

Load otb application from xml file

outxml

XML output parameters file

Save otb application to xml file











Table 4.2: Parameters table for Color Mapping.

Input Image Input image filename

Output Image Output image filename

Available RAM (Mb) Available memory for processing (in MB)

Operation Selection of the operation to execute (default is : label to color). Available choices are:

Color mapping method Selection of color mapping methods and their parameters. Available choices are:

Load otb application from xml file Load otb application from xml file

Save otb application to xml file Save otb application to xml file

Example

To run this example in command-line, use the following:

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

To run this example from Python, use the following code snippet:

#!/usr/bin/python 
 
# Import the otb applications package 
import otbApplication 
 
# The following line creates an instance of the ColorMapping application 
ColorMapping = otbApplication.Registry.CreateApplication("ColorMapping") 
 
# The following lines set all the application parameters: 
ColorMapping.SetParameterString("in", "ROI_QB_MUL_1_SVN_CLASS_MULTI.png") 
 
ColorMapping.SetParameterString("method","custom") 
 
ColorMapping.SetParameterString("method.custom.lut", "ROI_QB_MUL_1_SVN_CLASS_MULTI_PNG_ColorTable.txt") 
 
ColorMapping.SetParameterString("out", "Colorized_ROI_QB_MUL_1_SVN_CLASS_MULTI.tif") 
 
# The following line execute the application 
ColorMapping.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.

Authors

This application has been written by OTB-Team.

See also

These additional ressources can be useful for further information: