[Image-SIG] Saving 16bit tiffs

Scott Rifkin scott.rifkin at yale.edu
Sun Feb 15 17:05:19 EST 2004


I am trying to do the following:

1) read a 16-bit tiff image 
2) extract a rectangle from it
3) do a two-dimensional Fourier transform on the extracted rectangle-I do 
this by the getdata function, reshaping it into a Numeric array, and 
calling fft2d on it.
4) remove some of the lower frequency contribution
5) take the inverse Fourier transform
6)paste that back into the original image
7) save the image as a 16-bit tiff to a new file

I've narrowed down one problem to step 6.

Here's the code skipping the fft stuff (I might ask about that in a 
future post).  This just reads the image, crops it, gets the data, puts 
the data back, pastes it back, and saves it to a different file.

im=Image.open(image_file_name).copy()
cr=im.crop(tuple(bound)) #bound is a 4 tuple with the rectangle coords
data=reshape(array(cr.getdata()),(cr.size[1],cr.size[0]))
print cr.getpixel((0,0))
cr.putdata(ravel(data))
print data[0]
print cr.getpixel((0,0))
im.paste(cr,tuple(bound))
im.save(new_image_file_name)


when i run it, the three  print statements come out as:
136
136
33928

something weird has happened in the putdata part.

thanks in advance for any help,
scott rifkin







More information about the Image-SIG mailing list