[GRASSLIST:1493] Re: GDAL with CIR-photos

Glynn Clements glynn.clements at virgin.net
Tue Oct 14 10:17:24 EDT 2003


Frank Warmerdam wrote:

> >  I imported pseudocolor-Fotos with GDAL, they`re scanned as a *.jpg
> >  (o.k., this is maybe a challenge).
> >  As they always appear splittet into RGB-Channels, what about the
> >  Magenta, which is so important to handle the information in the
> > photos?
> >  I assume this color-information is splitted through additive
> >  colorcomposition into blue and red? So maybe the blue channel shows a
> >  part of the magenta color? 
> > Is there maybe a loss of information now using GDAL? 
> > Is there any experience on that, or does somebody know how the
> >  GDAL-library handles this?
> 
> If the input JPEG file is in the YCbCr "color space" it will be automatically
> translated to RGB by libjpeg (under GDAL).  You mention Magenta.  While I don't
> know too much about YCbCr I don't think it is exactly the same as CMY (Cyan,
> Magenta Yello) or CMYK color space which includes a magenta component.
> 
> For most purposes the RGB color representation should be as expressive as the
> original color space, though there is undoubtedly some slight color degredation
> occuring in the color space translation.

The conversion between RGB and CMY is trivial and reversible:

	C = 1 - R	R = 1 - C
	M = 1 - G	G = 1 - M
	Y = 1 - B	B = 1 - Y

Both colour spaces describe the same colour cube, but from opposite
corners: in RGB, <0,0,0> is black, in CMY, it's white; increasing
values result in lighter colours in RGB, darker in CMY.

Any degradation is likely to be caused by (mis)correcting for the
colour gamut of the output device (e.g. gamma correction).

The colour magenta is <1,0,1> (red + blue) in RGB, <0,1,0> (magenta)
in CMY.

The K (black) channel in CMYK is to compensate for the fact that using
equal amounts of cyan, magenta and yellow inks should produce black
but doesn't, so some amount of black ink is used as well. There isn't
any one true conversion for CMY->CMYK; normally the conversion is done
by the printer, and is tuned to the properties of the ink/toner (and
possibly those of the paper).

BTW, YCbCr is given by:

	Y  =   0.299  R + 0.587  G + 0.114  B
	Cb = - 0.1687 R - 0.3313 G + 0.5    B
	Cr =   0.5    R - 0.4187 G - 0.0813 B

	R = Y              + 1.402   Cr
	G = Y - 0.34414 Cb - 0.71414 Cr
	B = Y + 1.772   Cb

Y is in the range 0 to 1, Cb/Cr are -0.5 to +0.5.

The point of YCbCr is that one of the components (Y) is the luminance
(grey-scale equivalent). In a JPEG image, the Cb and Cr channels are
stored at half the resolution of the Y channel, as the human eye has
better resolution for intensity than for hue.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-user mailing list