1 year ago
#354092
Mayank
How to convert a 10 bit grayscale image to 8 bit image?
I am trying to convert a a 10 bit grayscale image to 8 bit (using python). But I am not able to find a solution yet. The problem with 10 bit image is that I cannot view it in windows, it is showing blank image. Though the image is viewable with ImageJ tool. How can this be done?
The image is in .PNG format and the output is also expected to be in same format. The image is taken from camera and stored in local.
UPDATE: I tried the below code, now I am able to view the image but the image is different from original colors.
from PIL import Image
im = Image.open("sample.png")
im = im.convert('RGB')
r, g, b = im.split()
r = r.point(lambda i: i * 64)
b = b.point(lambda i: i * 64)
g = g.point(lambda i: i * 64)
out = Image.merge('RGB', (r, g, b))
out.show()
I also tried the convert(L) method in PIL, it gave better result but still missing the original colors of image.
python-3.x
image-processing
imagej
0 Answers
Your Answer