I am using GDAL (gdal_merge) to put together some landsat photos using the proper bands. When I open the GeoTIFF that is created using gdal_merge (in Windows), the GeoTIFF is super dark. Now, when I open the same GeoTIFF in ArcMap, it's nice and bright and realistic looking. I was wondering if there was a function in GDAL that would allow me to do what ArcMap is doing.
I have tried using PIL (in python) to enhance the brightness, contrast, and color – and I have had some success, but certainly it's not as nice as what ArcMap is doing.
Does anyone have any ideas? Just in case you are wondering, the gdal_merge command is as follows
gdal_merge.py -separate -ps 16 16 -co PHOTOMETRIC=RGB -o "merged_new.tif" "LC08_L1TP_046029_20180717_20180717_01_RT_b4.tif" "LC08_L1TP_046029_20180717_20180717_01_RT_b3.tif" "LC08_L1TP_046029_20180717_20180717_01_RT_b2.tif"
But I don't think the gdal_merge command is an issue, as I am opening the result of gdal_merge with arcmap and it looks nice.
Best Answer
ArcMap
stretches the values of a raster automatically by some clip algorithm (percent clip
).You can use
gdal_translate -scale
option to "scale"/stretch the values.So you need to find out the right values by yourself. Use
gdalinfo -hist merged_new.tif
to find see the values of the file.Assuming most values (98%) lie between values of 20 and 150, we can do this:
For your Landsat scene, you posted this information:
That is a 16 Bit image. If you want an 8bit (=Byte) image to view it in an image viewer, you need to scale down the values with something like this
-ot Byte -scale 0 65535 0 255
to keep all values, or you can cut at the maximum:-ot Byte -scale 0 35050 0 255
.But that will probably still be too dark, as your mean is 3832 and stddev is 4860, so you might even want
-ot Byte -scale 0 16384 0 255
. As you will then cut some high values, you will lose information in very bright spots like clouds and glaciers.Related: