搜索内容

有一个问题?

如果您有任何疑问,可以在下面询问或输入您要寻找的!

C++,OpenCV矩阵计算

技术聚客 未结 1 440
weixin_40780523
weixin_40780523 2021-03-08 00:13

代码中的tem = 255 * (tem - Min) / (Max - Min);

如何理解。

代码如下:

ReadLongWMat.create(512, 640, CV_16UC1); LongW_FANMat.create(512, 640, CV_16UC1); cv::flip(ReadLongWMat, LongW_FANMat, 0); unsigned short* pData = (unsigned short*)(LongW_FANMat.data); short tem = 0, Max = 0, Min = 32767; for (int i = 0; i < 640; i++) { for (int j = 0; j < 512; j++) { tem = ((*(pData + (j * 640 + i)))); if (Max < tem) Max = tem; if (Min > tem) Min = tem; } } if (Max - Min <= 0) { Min--; Max++; } for (int i = 0; i < 640; i++) { for (int j = 0; j < 512; j++) { tem = ((*(pData + (j * 640 + i)))); tem = 255 * (tem - Min) / (Max - Min); //什么原理 if (tem > 255) tem = 255; else if (tem < 0) tem = 0; ShowLongWMat.data[j * 640 + i] = tem; } }
相关标签:
1条回答
  • 2021-03-08 00:25

    应该是将tem的值归一化到0-255之间,变成灰度图

    0 讨论(0)
提交回复