Posts

Showing posts with the label tiff

Working with TIFFs (import, export) in Python using numpy

Working with TIFFs (import, export) in Python using numpy I need a python routine that can open and import TIFF images into numpy arrays, so I can analyze and modify the contained data and afterwards save them as TIFFs again. (They are basically light intensity maps in greyscale, representing the respective values per pixel) I tried to find something, but there is no documentation on PIL methods concerning TIFF. I tried to figure it out, but only got bad mode/ file type not supported errors. What do I need to use here? 6 Answers 6 First, I downloaded a test TIFF image from this page called a_image.tif . Then I opened with PIL like this: a_image.tif >>> from PIL import Image >>> im = Image.open('a_image.tif') >>> im.show() This showed the rainbow image. To convert to a numpy array, it's as simple as: >>> import numpy >>> imarray = numpy.array(i...