Using convertTo corrupts the image

asked 2020-04-08 20:24:48 -0600

alittlebirdy gravatar image

updated 2020-04-08 20:26:25 -0600

I have an image that is 3 channels, 16 bit depth. I am trying to convert it to 8 bits using this:

img.convertTo(img, CV_8U, 0.00390625);

(source: https://stackoverflow.com/questions/6...)

While this does work and converts it to 8 bits, it corrupts my image in the process. My previous image looks like this: image description

After using convertTo my image now looks like this: image description

Any suggestions why this is?

edit retag flag offensive close merge delete

Comments

curious: how did you get the 1st image ? (which is 24 == 3 x 8 bits)

while your scale factor is correct in theory, you pixel ranges might still be in [0..255]

berak gravatar imageberak ( 2020-04-09 03:52:45 -0600 )edit

I got the first image by stitching three separate images together. Can you explain what you mean by scale factor vs pixel ranges? Still not sure how to fix this.

alittlebirdy gravatar imagealittlebirdy ( 2020-04-09 10:01:48 -0600 )edit