I'm working with 16bit gray-scale images but I'm having some problems with drawing and higher order interpolation.
Nearest-neighbor interpolation works fine, but anything else corrupt the image. I'm using version 1.1.7 on win32 that comes with Python(x,y). If I convert the images to mode "I" (32bit int) and then back to "I;16" it seems to work fine. I looked through libImaging for the interpolation code. It looks like it is off by half in the width, uUsing a 32bit stride rather than 16 bit stride. I don't have time right now to learn the codebase and make the fix but maybe someone more familiar, more motivated or with more time can. The code below shows the problem and workaround. ---------------------------------------------------------- import Image, ImageDraw def draw_doodle( img ): draw = ImageDraw.Draw(img) (width,height) = img.size width = width - 1 height = height -1 draw.line( (0, 0, width, height ), fill="#FFFFFF") draw.line( (width, 0, 0, height ), fill="#CCCCCC") draw.line( (0, height/2, width, height/2), fill="#888888") # Make a blank tiff file = r'dummy.tif' blank = Image.new("I;16", (80,123)) blank.save( file ) # Draw on image im16 = Image.open( file ) draw_doodle( im16 ) print im16 im16.show() #Scale it im16s = im16.resize((80,126), Image.BILINEAR ) im16s.show() # Now do it after converting to I type im16 = Image.open( file ) im32 = im16.convert("I") draw_doodle( im32 ) print im32 im32.show() #Scale it im32s = im32.resize((80,126), Image.BILINEAR ) im = im32s.convert("I;16") print im im.show() Chuck
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig