这个想法是对的。但是请记住在缩放之前将OpenCV Mats转换为float或double类型。
就像是:
cv::Mat mat; // assume this is one of your images (grayscale) /* convert it to float */ mat.convertTo(mat, CV_32FC1); // use CV_32FC3 for color images /* scaling here */ mat = mat * 0.00390625;
的 更新#1 强> :转换和缩放也可以简单地在一行中完成,即
cv::Mat mat; // assume this is one of your images (grayscale) /* convert and scale here */ mat.convertTo(mat, CV_32FC1, 0.00390625);