1 #include<opencv2/opencv.hpp> 2 #include<iostream> 3 4 using namespace std; 5 using namespace cv; 6 7 int main() 8 { 9 Mat mat1 = Mat(2, 2, CV_32FC1); 10 mat1.at<float>(0, 0) = 1.0f; 11 mat1.at<float>(0, 1) = 2.0f; 12 mat1.at<float>(1, 0) = 3.0f; 13 mat1.at<float>(1, 1) = 4.0f; 14 // 對於這種小矩陣,還有更簡單的賦值方式,找時間再改 15 cout << "Mat 1:" << endl; 16 cout << mat1 << endl; 17 18 normalize(mat1, mat1, 1.0, 0.0, NORM_MINMAX); 19 cout << "Mat 2:" << endl; 20 cout << mat1 << endl; 21 }

參考:
