When I use cv::Mat is it the same as np.array(3,2,3)?
cv::Mat mat_32f_C3(mat.rows, mat.cols, CV_32FC3);
mat_32f_C3.at<cv::Vec3f>(0,0) = cv::Vec3f(1,1,1);
mat_32f_C3.at<cv::Vec3f>(0,1) = cv::Vec3f(2,2,2);
mat_32f_C3.at<cv::Vec3f>(1,0) = cv::Vec3f(3,3,3);
mat_32f_C3.at<cv::Vec3f>(1,1) = cv::Vec3f(4,4,4);
mat_32f_C3.at<cv::Vec3f>(2,0) = cv::Vec3f(5,5,5);
mat_32f_C3.at<cv::Vec3f>(2,1) = cv::Vec3f(6,6,6);
I am not sure if the cv::Vec3f
represents RGB in a color image.
In python I would write
broadcast = np.zeros((3,2,3))
i1 = np.pad(np.arange(1, 7, 1).reshape((3,2)), 2, 'constant').reshape(7,6,1)
result = i1 + broadcast
output array([[[[1., 2.],
[3., 4.],
[5., 6.]],
[[1., 2.],
[3., 4.],
[5., 6.]],
[[1., 2.],
[3., 4.],
[5., 6.]]]])
Are thos examples the same?
Aucun commentaire:
Enregistrer un commentaire