opencv 将Mat类型从CV_32F转CV_8U

最近遇到mat转换所以记录一下

1,如果直接convertTo转换的话,转换出来的就是一块黑,什么也没用

      Mat src = imread(imagepath.toStdString().c_str(), 0);
        cv::Mat butterworth = Butterworth_Low_Paass_Filter(src, 100, 2);
        butterworth = butterworth(cv::Rect(0, 0, src.cols, src.rows));
        cv::Mat MatTemp2;
        double Min = 0.0, Max = 0.0;
        double* minp = &Min;
        double* maxp = &Max;
        minMaxIdx(butterworth, minp, maxp);
        if (Min!=Max){
            butterworth.convertTo(MatTemp2,CV_8U,255.0/(Max-Min),-255.0*Min/(Max-Min));//转换
        }

你可能感兴趣的:(opencv,opencv,python)