DIPlib Documentation - ©1995-2008 Quantitative Imaging Group, Delft University of Technology.

Colour2Gray

Convert ND image with colour information to a (n-1)D grayvalue image (in dipIO)

SYNOPSIS

#include "dipio_tools.h"

dip_Error dipio_Colour2Gray ( in, out, photometric )

FUNCTION

This function converts a colour image, as read by ImageReadColour, to a grayvalue intensity image. in is expected to contain the colour information along the last axis. out will be a scalar image with one less dimension than the input.

ARGUMENTS

Data typeNameDescription
dip_ImageinInput image
dip_ImageoutOutput image
dipio_PhotometricInterpretationphotometricPhotometric interpretation

The enumerator dipio_PhotometricInterpretation contains the following constants:

NameDescription
DIPIO_PHM_GREYVALUENo colour information present; it's a grey-value image.
DIPIO_PHM_RGBRGB image (the first three planes are red, green and blue)
DIPIO_PHM_RGB_NONLINEARNon-linear R'G'B' image (RGB channels to the power of 0.4)
DIPIO_PHM_CMYCMY image (the first three planes are cyan, magenta and yellow)
DIPIO_PHM_CMYKCMYK image (the first four planes are cyan, magenta, yellow and black)
DIPIO_PHM_CIELUVCIE L*u'v' image (the first three planes are luminosity, u* and v*)
DIPIO_PHM_CIELABCIE L*a*b* image (the first three planes are luminosity, a* and b*)
DIPIO_PHM_CIEXYZCIE XYZ (the first three planes are X, Y and Z)
DIPIO_PHM_CIEYXYCIE Yxy (the first three planes are Y, x and y)
DIPIO_PHM_HCVHCV image (the first three planes are hue, chroma and value)
DIPIO_PHM_HSVHSV image (the first three planes are hue, saturation and value)
DIPIO_PHM_DEFAULTSame as DIPIO_PHM_GREYVALUE
DIPIO_PHM_GENERICAnything can be coded in the channels; the same as DIPIO_PHM_CMYK

Most file formats support only some of these.

KNOWN BUGS

Some colourspaces are not converted correctly. R'G'B' (DIPIO_PHM_RGB_NONLINEAR), is treated like RGB. From a CIE Lab (DIPIO_PHM_CIELAB) or Luv (DIPIO_PHM_CIELUV) the luminosity channel is extracted, which is also a non-linear conversion away from the intensity. From HCV (DIPIO_PHM_HCV) and HSV (DIPIO_PHM_HSV) the value channel is extracted, which again is a non-linear conversion away from the intensity. CMYK (DIPIO_PHM_CMYK) and CMY (DIPIO_PHM_CMY) conversion is not implemented. Specifying these values will result in an error.

SEE ALSO

ImageRead, ImageReadColour, ImageReadROI

DIPlib on-line documentation | Function reference | Global function index