I generated composite images of Landsat 8 SR images using this Google Earth Engine collection, and for a machine learning project now I need to transform the RGB bands of these images to 8-bit colors.

I'm using Python, I downloaded my composite images as .TIFF, and following some answers to other questions like this one, I tried the following to convert the RGB part of my images to 8-bit colors:

#loading packages
import imageio
import matplotlib.pyplot as plt

#reading the image

#taking GRB channels from the image, reordering them to RGB, and converting colors to 8-bits


I took the image, kept the RGB bands only (so I can visualize it), and divided by 255 (since original colors are 16-bit) and took away the decimal part to get only integers, but I obtain the following when plotting:

The image_test.tif file can be found here. I also visualized my image using GEE, and it should look like this (I used visualization parameters 'min': 0, 'max': 3000, 'gamma': 1.4):

How do I correctly convert the color in these images?

1 Answer 1


The most efficient way to do this would be to export it as an 8-bit image to begin with.



If that's not an option, you can do it directly in Python, but you don't want to divide by 256. Instead, multiply with the scale of the image (0.0001 in your case) to get it between 0 and 1, then multiply by 256.

  • Thank you, this worked. I cannot re-export them, but multiplying by the scale and 256 worked perfectly. Here is how it looks now, which is exactly how it should look without the gamma corrections and stuff. Nov 23, 2022 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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