save 16 bit images [closed]

asked 2015-05-16 20:13:17 -0500

NabeelKhan gravatar image

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
edit retag flag offensive reopen merge delete

Closed for the following reason too subjective and argumentative by sturkmen
close date 2017-09-02 21:09:01.491579


are you sure, your "actualImage.jpg" has 16 bits on disk ?

berak gravatar imageberak ( 2015-05-17 03:30:12 -0500 )edit

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.

Flart gravatar imageFlart ( 2015-05-18 08:37:07 -0500 )edit