Scipy: Convert RGB TIFF to grayscale TIFF and output it on Matplotlib <p>I want to manipulate <strong>RGB</strong> bands in a TIFF file and output the <strong>grayscale</strong> map on matplotlib. So far I have this code, but I couldn't get it on grayscale:</p> <pre><code>import scipy as N import gdal import sys import matplotlib.pyplot as pyplot tif = gdal.Open('filename.tif') band1 = tif.GetRasterBand(1) band2 = tif.GetRasterBand(2) band3 = tif.GetRasterBand(3) red = band1.ReadAsArray() green = band2.ReadAsArray() blue = band3.ReadAsArray() gray = (0.299*red + 0.587*green + 0.114*blue) pyplot.figure() pyplot.imshow(gray) pylab.show() </code></pre> <p>And these are the arrays:</p> <pre><code>[[255 255 255 ..., 237 237 251] [255 255 255 ..., 237 237 251] [255 255 255 ..., 237 237 251] ..., [237 237 237 ..., 237 237 251] [237 237 237 ..., 237 237 251] [242 242 242 ..., 242 242 252]] [[255 255 255 ..., 239 239 251] [255 255 255 ..., 239 239 251] [255 255 255 ..., 239 239 251] ..., [239 239 239 ..., 239 239 251] [239 239 239 ..., 239 239 251] [243 243 243 ..., 243 243 252]] [[255 255 255 ..., 234 234 250] [255 255 255 ..., 234 234 250] [255 255 255 ..., 234 234 250] ..., [234 234 234 ..., 234 234 250] [234 234 234 ..., 234 234 250] [239 239 239 ..., 239 239 251]] </code></pre> <p>Any idea how can I fix this?</p>