4

I'm attempting to use gdal_merge to stitch together four JP2 aerial orthophotos. the merge is successful, but the resulting image has washed out color, as you can see here:

enter image description here

All color in the four original tiles looks fine before the merge.

The line I'm using to merge them is:

gdal_merge -o merged.tif -of GTiff 16SEJ790950_201103_0x1500m_4B_1.jp2 16SEJ790965_201103_0x1500m_4B_1.jp2 16SEJ805950_201103_0x1500m_4B_1.jp2 16SEJ805965_201103_0x1500m_4B_1.jp2

GDALINFO color information shows:

COLORSPACE = RGB

COMPRESSION_RATE_TARGET=2

Band 1 Block=256x256 Type=Byte, ColorInterp=Red Description = Red Overviews: 5000x5000, 2500x2500, 1250x1250, 625x625, 312x312, 156x156

Band 2 Block=256x256 Type=Byte, ColorInterp=Green Description = Green Overviews: 5000x5000, 2500x2500, 1250x1250, 625x625, 312x312, 156x156

Band 3 Block=256x256 Type=Byte, ColorInterp=Blue Description = Blue Overviews: 5000x5000, 2500x2500, 1250x1250, 625x625, 312x312, 156x156

Band 4 Block=256x256 Type=Byte, ColorInterp=Undefined Description = AllOpacityPremultiplied Overviews: 5000x5000, 2500x2500, 1250x1250, 625x625, 312x312, 156x156

  • 1
    What does gdalinfo report about your source images? – user30184 Jan 4 '17 at 21:54
  • Added GDALINFO color-related info to the question. – D. Waschow Jan 5 '17 at 13:25
  • 3
    Band 4 is interpreted to be alpha. Do you know if it is alpha or something else? For testing if alpha makes trouble drop it out from some images with gdal_translate. Use -b 1 -b 2 -b 3for creating plain RGB image. – user30184 Jan 5 '17 at 13:39
  • Alpha sounds like a good possibility. I hadn't come across premultiplied alpha before, that doesn't sound like the alpha channel behaviour I'd expect, which is like the 'straight alpha' described on that page. This might be a jp2 specific thing. – Steven Kay Jan 5 '17 at 21:00
1

It could just be that your combined image has a greater range of values and the colour stretch makes the new image look washed out.

0

I ran into this issue too. I had 4 geotiffs that were 4 band orthoimagery. You can check the bands using the Raster->Miscellaneous->Information... command. Here I can see that the images are 4 bands:

Band 4 Block=512x512 Type=Byte, ColorInterp=Undefined
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue

4 Individual Tiffs

After merging them together they were washed out:

Washed out Image


The issue was the resulting geotiff bands were identifying that there was an alpha band. I noticed this using the information tool on the result:

Band 1 Block=6000x1 Type=Byte, ColorInterp=Red
  Mask Flags: PER_DATASET ALPHA 
Band 2 Block=6000x1 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA 
Band 3 Block=6000x1 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA 

I could turn this off by going to Properties->Transparency. There I saw that the Transparency band was identified as Band 4 (which was NIR for my imagery)

Transparency Settings for Raster Images

If I set that to "None" the image will render correctly. However, if I want to merge them without the Mask Flags being added to the result, during the merge operation, I need to add a creation option for ALPHA with the value NO. Alternatively, you can edit the gdal command to add -co "ALPHA=NO".

This will prevent the Mask Flags from being added to the output, and the image will render correctly.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.