1 | initial version |
opencv has operators, that allow you to write it down exactly like you did above:
Vec3f v(1,2,3);
Matx33f M(1,1,1,
2,2,2,
3,3,3);
Vec3f u = M * v;
cout << u << endl;
[6, 12, 18]
(you can also use a "normal" cv::Mat, Matx33f was just "easier to fill" in the example)
2 | No.2 Revision |
opencv has operators, that allow you to write it down exactly like you did above:
Vec3f v(1,2,3);
Matx33f M(1,1,1,
2,2,2,
3,3,3);
Vec3f u = M * v;
cout << u << endl;
[6, 12, 18]
(you can also use a "normal" cv::Mat, Matx33f was just "easier to fill" in the example)
on the other hand, if it's for a whole image, you SHOULD NOT do this per-pixel, but use transform() instead.