Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cv2.resize() function changes 16 bit grayscale to 24 bit grayscale

When enlarging or shrinking with the cv2.resize function, 16-bit grayscale images are increased to 24 bits. Is there a way to resize them without changing the depth?

img=cv2.imread("16bitgray.tiff")

img512 = cv2.resize(img, (512,512), interpolation=cv2.INTER_NEAREST)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

If you read a 16-bit greyscale TIFF with:

img=cv2.imread("16bitgray.tiff")

you’ll get an RGB888 TIFF because that is the default. You need:

img=cv2.imread("16bitgray.tiff", cv2.IMREAD_UNCHANGED)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading