ColorModelConverter

MLModule
genre LUT
author MeVis Medical Solutions AG
package MeVisLab/Standard
dll MLColor
definition mlColor.def
see also ColorTable, ColorMatrix
keywords rgb, hsv, hsi, cmyk, lab, cmy, yiq, yuv, xyz

Purpose

The module ColorModelConverter converts the color model of an image to another color model.

Usage

Either set the module to Automatically convert to RGB to automatically detect the input image’s color model and to convert to RGB, or chose a specific conversion if the source color model is known.

If the number of input channels does not match to the chosen conversion mode, then an error is written to the MeVisLab’s debug console and the output is set to invalid.

Details

RGB

This color model is based on human perception of light. Every color can be broken down into the base colors red, green, and blue, similar to how the receptors in the human eye perceive them.

RGB is an additive color model. All gray values lie on the black-white diagonal. This model is used when the eye perceives the color directly, without reflection.

../../../Modules/ML/MLColor/mhelp/Images/colormodelrgb.gif ../../../Modules/ML/MLColor/mhelp/Images/cube_anim.gif ../../../Modules/ML/MLColor/mhelp/Images/ColorM2.gif

HSV

This model is based on the segmentation of color into hue, saturation, and value. It can be represented in the form of a cylinder or a cone.

The value is displayed on the z-axis, saturation is the distance from the cylinder’s axis, and hue is the angle on the color circle (blue at 240 degrees, green at 120 degrees, and red at 0 degrees).

../../../Modules/ML/MLColor/mhelp/Images/ColorM3.jpg ../../../Modules/ML/MLColor/mhelp/Images/hsvmodel.gif

HLS

Established 1979 from the Core committee (Graphics Standards Planning Committee).

H stands for Hue, L for Lightness, and S for Saturation.

It is similar to the HSV color model. Hue is the angle of the color circle, lightness is the gray value on the L-axis, and saturation is the distance from the L-axis.

../../../Modules/ML/MLColor/mhelp/Images/hlsmodel.gif

CMY

Is mostly used if the eyes perceive reflection of objects.

CMY is a subtractive color model and based on the fundamental colors cyan, magenta, and yellow. Those fundamental colors are complementary to the fundamental colors of RGB.

../../../Modules/ML/MLColor/mhelp/Images/colormodelcmy.gif ../../../Modules/ML/MLColor/mhelp/Images/ColorM7.gif

CMYK

Like CMY, but with an extra black part. It is useful in printing colors, because black is not exactly presentable (in printing) with the CMY model.

k(someK) = min(c,m,y)

YIQ

Defined by the American NTSC-standard (NTSC = National Television System Committee).

YIQ is backward compatible with black and white TV when only the Y component is used.

Y stands for luminance and is the primary parameter; I represents the red weight, and Q represents the blue weight of the luminance.

Y = Luminance

I = Red - Y

Q = Blue - Y

Conversion from YIQ to RGB:

../../../Modules/ML/MLColor/mhelp/Images/ColorM5.jpg

YUV

Defined by the European PAL standard (PAL = Phase Alternation Line). Same principle as YIQ.

Y = Luminance

I = 0.493 * (B-Y)

Q = 0.877 * (B-Y)

Conversion from YUV to RGB:

../../../Modules/ML/MLColor/mhelp/Images/ColorM6.jpg

XYZ

The XYZ color space was defined 1931 by the CIE (CIE = Comission Internationale d´Éclairage).

XYZ are standardized primary colors. Y is equivalent to the luminance, and X and Z contain color information.

The XYZ color space contains all colors - not only the visible ones. This model is machine-independent.

../../../Modules/ML/MLColor/mhelp/Images/ColorM8.gif ../../../Modules/ML/MLColor/mhelp/Images/cube.gif ../../../Modules/ML/MLColor/mhelp/Images/xyz_cube.gif

Conversion from XYZ to RGB:

var_X = X / 100        //Where X = 0 ...  95.047
var_Y = Y / 100        //Where Y = 0 ... 100.000
var_Z = Z / 100        //Where Z = 0 ... 108.883

var_R = var_X *  3.2406 + var_Y * -1.5372 + var_Z * -0.4986
var_G = var_X * -0.9689 + var_Y *  1.8758 + var_Z *  0.0415
var_B = var_X *  0.0557 + var_Y * -0.2040 + var_Z *  1.0570

if ( var_R > 0.0031308 ) var_R = 1.055 * ( var_R ^ ( 1 / 2.4 ) ) - 0.055
else                     var_R = 12.92 * var_R
if ( var_G > 0.0031308 ) var_G = 1.055 * ( var_G ^ ( 1 / 2.4 ) ) - 0.055
else                     var_G = 12.92 * var_G
if ( var_B > 0.0031308 ) var_B = 1.055 * ( var_B ^ ( 1 / 2.4 ) ) - 0.055
else                     var_B = 12.92 * var_B

R = var_R * 255
G = var_G * 255
B = var_B * 255

Conversion from RGB to XYZ:

var_R = ( R / 255 )        //Where R = 0 ... 255
var_G = ( G / 255 )        //Where G = 0 ... 255
var_B = ( B / 255 )        //Where B = 0 ... 255

if ( var_R > 0.04045 ) var_R = ( ( var_R + 0.055 ) / 1.055 ) ^ 2.4
else                   var_R = var_R / 12.92
if ( var_G > 0.04045 ) var_G = ( ( var_G + 0.055 ) / 1.055 ) ^ 2.4
else                   var_G = var_G / 12.92
if ( var_B > 0.04045 ) var_B = ( ( var_B + 0.055 ) / 1.055 ) ^ 2.4
else                   var_B = var_B / 12.92

var_R = var_R * 100
var_G = var_G * 100
var_B = var_B * 100

X = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805
Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722
Z = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505

CIE LAB

CIE L*a*b* (CIELAB) is the most complete color model used conventionally to describe all the colors visible to the human eye. It was developed for this specific purpose by the International Commission on Illumination (Commission Internationale d’Eclairage).

The three basic coordinates represent the lightness of the color (L*, where L* = 0 yields black and L* = 100 indicates white), its position between red/magenta and green (a*, where negative values indicate green while positive values indicate magenta) and its position between yellow and blue (b*, where negative values indicate blue and positive values indicate yellow). The L*a*b* color model has been created to serve as a device-independent reference model. It is important to note that the visual representations of the full gamut of colors in this model are never entirely accurate; they are merely conceptual aids and are inherently imprecise.

Uniform changes of components in the L*a*b* color model are intended to correspond to uniform changes in perceived color. In this way, the relative perceptual differences between any two colors in L*a*b* can be approximated by treating each color as a point in a three-dimensional space (with the three components: L*, a*, b*) and calculating the Euclidean distance between them.

Windows

Default Panel

../../../Modules/ML/MLColor/mhelp/Images/Screenshots/ColorModelConverter._default.png

Input Fields

input0

name: input0, type: Image

Output Fields

output0

name: output0, type: Image

Parameter Fields

Visible Fields

Direction Select

name: directionSelect, type: Enum, default: Identity

Defines a specific conversion.

Values:

Title Name Deprecated Name
Identity Identity RGB to RGB
RGB to HSV RGB to HSV  
HSV to RGB HSV to RGB  
RGB to CMY RGB to CMY  
CMY to RGB CMY to RGB  
CMY to CMYK CMY to CMYK  
CMYK to CMY CMYK to CMY  
CMYK to RGB CMYK to RGB  
RGB to CMYK RGB to CMYK  
RGB to HLS RGB to HLS  
HLS to RGB HLS to RGB  
RGB to YIQ RGB to YIQ  
YIQ to RGB YIQ to RGB  
RGB to YUV RGB to YUV  
YUV to RGB YUV to RGB  
RGB to XYZ RGB to XYZ  
XYZ to RGB XYZ to RGB  
RGB to LAB RGB to LAB  
LAB to RGB LAB to RGB  
XYZ to LAB XYZ to LAB  
LAB to XYZ LAB to XYZ  
RGB to Gray RGB to Gray  
Gray to RGB Gray to RGB  

Automatically convert to RGB

name: automaticConvert, type: Bool, default: FALSE

If checked, the module detects the input image’s color model automatically and converts it to RGB.

Info

name: info, type: String, persistent: no

Shows information about the conversion.