Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::Mat convertion to double type

Hi,

I am not really familiar with openCV, so I am probably using its functions wrong.

The code is as follows.

cv::Mat im0Bgr = cv::imread("colormapTest.png"); // 32x32 test image

cv::Mat im0BgrDouble;

im0Bgr.convertTo(im0BgrDouble, CV_32F);

// Then //

cv::namedWindow("Figure 1");

cv::namedWindow("Figure 2");

cv::imshow("Figure 1", im0Bgr);

cv::imshow("Figure 2", im0BgrDouble);

//... and destroyed just after

My original image is of type CV_8U. It is displayed correctly. My converted image is supposed to be in the range [0,1], while it is not ([0,255] instead). More than that, only the half top part is displayed, and the bottom half is displayed white, though the converted object contains some 0 there.

image description

Can someone point out where I am mistaken? I guess such a simple thing does not come from OpenCV. Thank you.

click to hide/show revision 2
retagged

cv::Mat convertion to double type

Hi,

I am not really familiar with openCV, so I am probably using its functions wrong.

The code is as follows.

cv::Mat im0Bgr = cv::imread("colormapTest.png"); // 32x32 test image

cv::Mat im0BgrDouble;

im0Bgr.convertTo(im0BgrDouble, CV_32F);

// Then //

cv::namedWindow("Figure 1");

cv::namedWindow("Figure 2");

cv::imshow("Figure 1", im0Bgr);

cv::imshow("Figure 2", im0BgrDouble);

//... and destroyed just after

My original image is of type CV_8U. It is displayed correctly. My converted image is supposed to be in the range [0,1], while it is not ([0,255] instead). More than that, only the half top part is displayed, and the bottom half is displayed white, though the converted object contains some 0 there.

image description

Can someone point out where I am mistaken? I guess such a simple thing does not come from OpenCV. Thank you.