opencv-meshgrid
一句话描述
使用opencv::repeat函数和std::iota函数完成meshgrid功能。
小例程
cv::Mat Z = cv::Mat::zeros(3, 5, CV_8UC1), X, Y;int x_length = Z.cols, y_length = Z.rows;std::vector<int> x(x_length);std::iota(x.begin(), x.end(), 1);X = cv::repeat(cv::Mat(x).t(), y_length, 1);std::vector<int> y(y_length);std::iota(y.begin(), y.end(), 1);Y = cv::repeat(cv::Mat(y), 1, x_length);
X | Y | Z |
---|---|---|
![]() | ![]() | ![]() |
通俗的说就是根据Z的大小生成X矩阵,Y矩阵