save 16 bit images [closed]
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
are you sure, your "actualImage.jpg" has 16 bits on disk ?
May be there are some function in processing, what convert your image to 8UC3? Check docs to every function, what you are use, or use Image Watch Extensions for Visual Studio.