[Gdal-dev] Conversion to Grayscale

Chris Hodgson chodgson at refractions.net
Fri Dec 3 14:17:18 EST 2004


Yes, these are full color images and I would like a reasonably "correct" 
grayscale representation.. I somehow got the notion that simply 
averaging the RGB values would do this... but that sems to be wrong 
based on what Paint Shop Pro does... I don't know much about colorspace 
transformations... all I know is that it shouldn't take as long as 
imagemagick 'convert -colorspace gray' does.

My current problem seems to be that I can't get gdal-python to compile 
(see my next post).

Chris

>Chris, 
>
>Do you want a "proper" RGB to greyscale conversion or is
>it sufficient to just take any one of the bands and use it as
>greyscale?  I believe a "proper" conversion would involve
>a colorspace transformation on the RGB image into IHS or
>something like that, and then taking the intensity.  This is
>not conveniently available in GDAL but could be implemented
>in Python. 
>
>However, if the file is really just a greyscale image represented
>in RGB then you could use the -b switch to pick out one band
>from the source image to use as the output greyscale image. 
>
>eg. 
>
>gdal_translate -b 1 in.tif out.tif
>
>Best regards,
>  
>




More information about the Gdal-dev mailing list