Opencv C++ 圖片隨機賦值 顯示矩陣
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat imgRandu = Mat(200, 200, CV_8UC3);
randu(imgRandu, Scalar::all(0), Scalar::all(255));
imshow("imgRandu", imgRandu);
Mat r = Mat(10, 3, CV_8UC3);
randu(r, Scalar::all(0), Scalar::all(255));
cout << "R 矩陣輸出(默認格式)= " << endl << r <<endl;
cout << "R 矩陣輸出(Python)= " << endl <<format(r, Formatter::FMT_PYTHON)<< endl;
cout << "R 矩陣輸出(Numpy)= " << endl << format(r, Formatter::FMT_NUMPY) << endl;
waitKey(0);
destroyAllWindows();
}
函數說明
void cv::randu (
InputOutputArray dst,
InputArray low,
InputArray high
)