Skip to content Skip to sidebar Skip to footer

Can't Apply Image Filters On 16-bit Tifs In Pil

I try to apply image filters using python's PIL. The code is straight forward: im = Image.open(fnImage) im = im.filter(ImageFilter.BLUR) This code works as expected on PNGs, JPGs

Solution 1:

Your TIFF image's mode is most likely a "I;16". In the current version of ImageFilter, kernels can only be applied to "L" and "RGB" images (see source of ImageFilter.py)

Try converting first to another mode:

im.convert('L')

If it fails, try:

im.mode = 'I'im = im.point(lambda i:i*(1./256)).convert('L').filter(ImageFilter.BLUR)

Remark: Possible duplicate from Python and 16 Bit Tiff

Solution 2:

To move ahead, try using ImageMagick, look for PythonMagick hooks to the program. On the command prompt, you can use convert.exe image-16.tiff -blur 2x2 output.tiff. Didn't manage to install PythonMagick in my windows OS as the source needs compiling.

Post a Comment for "Can't Apply Image Filters On 16-bit Tifs In Pil"