I was using PIL
to convert some images from RGB to gray scale in pythonPython, but this code does not work well for GeoTIFF files. It seems that PIL
does not seem to work with with GeoTIFF files in particular.
I was using the code:
from PIL import Image
t = Image.open('testfile.tif')
gray_image = image.convert('L')
So I was wondering if there is a way to load an image in say rasterio
and then convert it to a gray scale array. Now I could manually do this by writing a simple function to matrix multiply the image array, BUT the files are pretty large and so I run into memory issues. So I would likely need to do a windowed read on the file.
If there is a convenience function in rasterio
or GDAL
for this, could someone point it out. I searched but could not find anything. Otherwise I can try to work on creating a windowed read. Thanks.