[gdal-dev] convert Grayscale to RGB and, after georeferencing, back

Mark Johnson mj10777 at googlemail.com
Fri Jun 17 00:01:43 PDT 2016


During the process georeferencing a Grayscale image, the image must be
converted to a RGB image (-expand rgb -ot Byte) before calling
gdal_translate setting the GCP's.

After gdalwarp, the image is of course then RGB (3 Bands)
- and is rendered looking as a Grayscale image in QGIS

My question is: how to convert this back to the original Grayscale?

I assume, during the '-expand', the gray values have been separated into
the 3 bands according to some default logic so that it renders as a
Grayscale image when viewed.

I have seen samples of converting a (truly) coloured image to Grayscale:
gdal_calc.py -A input.tif --A_band=1 -B input.tif --B_band=2 -C input.tif
--C_band=3 --outfile=result.tif --calc="A*0.2989+B*0.5870+C*0.1140"

Would it be something in this form?

Mark Johnson, Berlin, Germany
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160617/99559b5a/attachment-0001.html>


More information about the gdal-dev mailing list