4

I have a number of aerial photos containing both RGB and a near-infrared band. The images are in TIF-format, however I need to convert them to PNG without losing any of the bands. I have tried converting/exporting data in ArcMap, however this fails, unless I choose to "use renderer" in the "Export Data" dialogue, resulting in only 3 bands being saved.

I have also tried the GDAL-translate alghorhitm in QGIS, however this didn't seem to work either.

Do I have any other options?

7

This is a limitation of the PNG format. It only has 3 information channels (RGB), so one of your bands will be suppressed. If you really need to, you can save your NIR band as an alpha channel, but beware - you won't be able to access it easily. Neither QGIS nor ArcGIS allow allocating the alpha channel to one of its display channels. The information will still be there, but you'll only access it through image processing libraries.

Why PNG, though? This is quite a non-standard for geographic images (for starters, you don't retain georeference). If you need a small file size, consider ECW or MrSid. If you need to open it in non-GIS software, GeoTiff is a good alternative, as TIF is supported by pretty much every image software. If you really need it saved as PNG, though, what you can do is save one image with red, green and blue bands in the RGB channels, and another image with, say, red, green and NIR in the RGB channels. Then reconstruct them into one single multiband image later on. Even in this last approach, JPEG2000 is the better alternative, as you don't lose spatial information.

  • The images will be used as inputs for a TensorFlow-model, and TensorFlow only supports jpeg, png and gif. Does jpeg support 4 bands? – Chrisnizz Dec 28 '17 at 11:30
  • 2
    Sorry, no. Neither of them do, as they were made for image visualization only, hence why tiff is the go-to format for printing (as it supports CMYK, amongst other reasons). If you want to feed your bands to TensorFlow, you can upload each band as a separate greyscale png image, and stick them all together into a row x col x 4 array. – Roberto Ribeiro Dec 28 '17 at 13:17
2

I will just answer my own question here, if anyone runs into the same problem with multiband images and TensorFlow.

I ended up using Keras on top of TensorFlow and instead of feeding the image files into the network, I converted my tiff-files to numpy arrays and appended all of them to the same array, which I saved as a .npy-file. In this way I avoided the trouble of multiband PNGs altogether.

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.