Repository navigation
GaussianBlur does not work with I;16 #6667
Description
Activity
Just an explanation from the code.
Pillow/src/libImaging/Filter.c
Lines 326 to 332 in 1f5be89
ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32 *kernel, FLOAT32 offset) { Imaging imOut; ImagingSectionCookie cookie; if (!im || im->type != IMAGING_TYPE_UINT8) { return (Imaging)ImagingError_ModeError(); }
means that it doesn't supportI,I;*,ForBGR;*.- changed the title
[-]ImageFilter does not work with 16-bit images[/-][+]ImageFilter does not work with I or I;16[/+]on Oct 21, 2022 PR #7108 has been merged, fixing this for I mode.
- changed the title
[-]ImageFilter does not work with I or I;16[/-][+]ImageFilter does not work with I;16[/+]on May 3, 2023 Hi!
When I useImageFilterto performs a look-up table (LUT) transform on an image of modeIorI;16,File ".../PIL/ImageFilter.py", line 560, in filter return image.color_lut_3d( ValueError: image has wrong modestill occurred.
I found that I mode has been supported for
BuiltinFilterbut still not supported forColor3DLUT.
Related code:
https://github.com/python-pillow/Pillow/blob/main/src/libImaging/ColorLUT.c#L89-L92Would mode
Ibe supported forColor3DLUTin the future?Thanks for your reply.
I'm sorry, I misunderstood.
I thought modeIsupported 3-channel 32-bit images, however it only supports 1-channel.I am trying to perform a look-up table (LUT) transform on heif images which are in 10-bit & 3-channel.
Now I find that Pillow only supports 8-bit color depth for 3-channel images (<- Am I right?), so the only way is to convert the 10-bit images to 8-bit in advance, even though it will reduce the amount of color information.Now I find that Pillow only supports 8-bit color depth for 3-channel images
Yes, see #1888
so the only way is to convert the 10-bit images to 8-bit in advance, even though it will reduce the amount of color information.
If your goal is to use the final image with Pillow, then yes.
If your goal is to use the final image with something else, then I suppose you would split 10-bit 3-channel images to 3 10-bit 1-channel images in advance, then use Pillow to handle the LUT, and then merge the images again outside of Pillow.If your goal is to use the final image with something else, then I suppose you would split 10-bit 3-channel images to 3 10-bit 1-channel images in advance, then use Pillow to handle the LUT, and then merge the images again outside of Pillow.
Oh! Thanks for your suggestion!
split 10-bit 3-channel images to 3 10-bit 1-channel images in advance, then use Pillow to handle the LUT
Again, this wouldn't 3D LUT, this will be three 1D LUTs.
Still does not work on I;16
Also does not work with gaussian blur filtersReacted by Lam Tran#8438 has been merged to support I;16 modes with
ImageFilter.BLUR. Pillow 11 is due to be released in a week with this feature.- changed the title
[-]ImageFilter does not work with I;16[/-][+]GaussianBlur does not work with I;16[/+]on Oct 10, 2024 @radarhere I think this can be closed, since Pillow 11 was released a while ago. #9760 will speed up #8438 though.
I don't think so, because
GaussianBlurstill isn't supported.>>> from PIL import Image, ImageFilter >>> im = Image.new("I;16", (1, 1)) >>> im.filter(ImageFilter.GaussianBlur) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "IL/Image.py", line 1458, in filter return self._new(filter.filter(self.im)) File "PIL/ImageFilter.py", line 206, in filter return image.gaussian_blur(xy) ValueError: image has wrong mode
Reacted by Aarni KoskelaReacted by Aarni Koskela

What did you do?
Attempted to use Image.filter(ImageFilter.BLUR) on an image of mode I or I;16
What did you expect to happen?
Image is blurred
What actually happened?
Code throws ValueError
What are your OS, Python and Pillow versions?