I am loading 16 bit image using openCV
in Python. 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 a 16-bit. I suspect that performing operations on numpy
array somehow changes the type of the array?
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
# # colour-transformed
# # into grayscale-16bit
# # colordepth