Reputation: 18178
I have this code:
Mat image00=imread("C:\\Working Dir\\Tests\\TestBlending\\layer0000.jpg");
Mat image0;
image00.convertTo(image0,CV_32FC3);
But after converting my image to float, the image is blank (all values are zero).
What is wrong with this code and how can I fix it?
Upvotes: 4
Views: 32001
Reputation: 2106
Try these:
1) image00.convertTo(image0, CV_32FC3, 1/255.0);
Mat Image type CV_8UC3
, value is from 0 to 255. While CV_32FC3
is between 0.0 and 1.0, hence you have to scale it. If I am not wrong, you receive all zero values as the image consist of mainly BGR values under 125? If it still doesn't work, try this:
2)
//CvType
image00.convertTo(image0, CvType.CV_32FC3, 1/255.0); //with or without scaling, try both
Should solve your problem(:
Upvotes: 11