[gdal-dev] RGB to Grayscale

Jukka Rahkonen jukka.rahkonen at maanmittauslaitos.fi
Fri Apr 17 14:22:44 PDT 2015


Tomer <tomerlieber <at> gmail.com> writes:

> 
> Hello,
> 
> I want to change a rgb image to a grayscale image.
> Is there a way to make it through the gdal_translate.exe utility or through
> other utilities.

I guess that gdal_calc.py is your friend http://www.gdal.org/gdal_calc.html.

Syntax could be something like

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"

Formula taken from
http://www.mathworks.com/matlabcentral/answers/99136-how-do-i-convert-my-rgb-image-to-grayscale-without-using-the-image-processing-toolbox

Send a mail and tell us the right syntax after your success and I will add
it into the gdal_calc document as one new example because this feels like a
task of general interest.

-Jukka Rahkonen-



More information about the gdal-dev mailing list