Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

save 16 bit images

I am loading 16 bit image using openCV. Then I do some processing on it and save it back on the disc using imwrite function of openCV. Surprisingly, the image is rescaled between 0-255

On the other hand, if I save image without any processing on the disc using imwrite then image is saved as 16 -bit

What's going on? Do I need to apply some conversion after processing? My code is:

img16Bit = cv2.imread('map.pgm',-1)
imwrite("actualImage.jpg", img16Bit)         # works fine

# does some processing on img16Bit
imwrite('processedImage.jpg', img16Bit)    # image is scaled bw 0-255