Ask Your Question

Revision history [back]

Just an addition to @pi-null-mezon's answer.

Before converting image type from 32S to 8U, you must normalize the image. For that you don't need to create your own algorithm, OpenCV has a normalize function

This call

cv::normalize(inMat, outMat, CV_MINMAX, 0, 255)

Will transform the smallest pixels to 0, the highest one to 255, and all the in-between accordingly to the right proportion. After that, you convert outMat to 8U and you are ready to display it.

Just an addition to complement @pi-null-mezon's answer.

Before converting image type from 32S to 8U, you must normalize the image. For that you don't need to create your own algorithm, OpenCV has a normalize function

This call

cv::normalize(inMat, outMat, CV_MINMAX, 0, 255)

Will transform the smallest pixels to 0, the highest one to 255, and all the in-between accordingly to the right proportion. After that, you convert outMat to 8U and you are ready to display it.