Ask Your Question

Revision history [back]

Using convertTo corrupts the image

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/6909464/convert-16-bit-depth-cvmat-to-8-bit-depth)

While this does work and converts it to 8 bits, it corrupts my image in the process. My previous image looks like this: C:\fakepath\cropped.png

After using convertTo my image now looks like this: C:\fakepath\cropped2.png

Any suggestions why this is?

Using convertTo corrupts the image

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/6909464/convert-16-bit-depth-cvmat-to-8-bit-depth)

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

After using convertTo my image now looks like this: C:\fakepath\cropped2.png image description

Any suggestions why this is?