-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageEnhance is not working on 16 bit images #7397
Comments
This is hitting Lines 26 to 30 in fce23dd
Could you upload a copy of the image? |
here is the sample image |
Ok. Be aware that's a PNG file with a palette, rather than a 16-bit TIFF, so that's different. If you would like an immediate solution, you can convert it to a different mode, from PIL import Image, ImageEnhance
im = Image.open('in.png').convert('RGB')
enh = ImageEnhance.Contrast(im)
enh.enhance(1.3).show("30% more contrast") |
Currently Pillow doesn't coerce images to required mode for most operations. This is not unique to |
@ghoshben the previous comment suggests that converting is actually the ultimate solution here. Does that resolve this for you? |
my bad that webserver converted that tif to png . here is the link to the file - https://drive.google.com/file/d/16bN5o_1WoRCHElC1sSPDpiZ82GGWwikr/view?usp=sharing |
The same solution applies, just with some scaling in the middle to account for the fact that it is an I;16 image and Pillow doesn't scale automatically when converting. from PIL import Image, ImageEnhance
im = Image.open("in.tif").point(lambda x: x / 256).convert("L")
enh = ImageEnhance.Contrast(im)
enh.enhance(2).show("30% more contrast") |
aah okay. But that will reduce quality right? as we are almost reduction the information by 1/2? |
@homm did you have any further thoughts? |
Worse, it will reduce amount of information in 256 times. But still, Pillow doesn't have 16-bit-per-channel support in the first place. |
What did you do?
Simply wanted to increase contrast
What did you expect to happen?
contrast would increase
What actually happened?
it thrown an error saying image has wrong mode
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: