opencv的Mat浮点矩阵相加相除运算


直接上代码

int main(int argc ,char *argv[])
{
//offline_test_Array();
Mat img2(Map_Size, Map_Size, CV_8UC1, cv::Scalar(0)); 
Mat Map_log_sonar2= Mat(Map_Size, Map_Size, CV_64F,cv::Scalar(4.0));
imshow("img2",img2);
waitKey(0);
img2 = (1 / ( 1 + Map_log_sonar2));
//resize(src, dst, cv::Size(1000, 1000));
resize(img2,img2,Size(1000,1000));
unsigned int StrawCovRate = img2.at<uchar>(10,10);
std::string text = "value:";
ostringstream oss;
oss<<StrawCovRate;
text.append(oss.str());
putText(img2, text, Point(100,150), FONT_HERSHEY_COMPLEX, 2, cv::Scalar(0, 255, 255), 2, 8, 0);

imshow("Map_log",img2);
waitKey(0);
}

微信截图_20210409181426.png





浮点矩阵变成CV8U1后实际上的值是 255*小数点。


sitemap