OpenCV Mat 四则运算符实现矩阵运算

Mat 数据类型可以直接利用某些数学四则运算符进行矩阵的运算.

如下解释:

  OpenCV referance manual  P461

Matrix Expressions
This is a list of implemented matrix operations that can be combined in arbitrary complex expressions
(here A, B stand for matrices (Mat), s for a scalar (Scalar),
for a real-valued scalar
(double)):
addition, subtraction, negation: A B; A s; s A; A
scaling: A*
, A/

per-element multiplication and division: A.mul(B), A/B, α/A
matrix multiplication: A*B
transposition: A.t() At
matrix inversion and pseudo-inversion, solving linear systems and least-squares problems:
A.inv([method]) A1, A.inv([method])*B X : AX = B
comparison: A T B; A 6= B; A T
; A 6=
. The result of comparison is 8-bit single channel
mask, which elements are set to 255 (if the particular element or pair of elements satisfy the
condition) and 0 otherwise.
bitwise logical operations: A & B, A & s, A | B, A | s, A ˆB, A ˆs, ˜A
element-wise minimum and maximum: min(A, B), min(A,
), max(A, B), max(A,

)
element-wise absolute value: abs(A)
cross-product, dot-product: A.cross(B), A.dot(B)

any function of matrix or matrices and scalars that returns a matrix or a scalar, such as
cv::norm, cv::mean, cv::sum, cv::countNonZero, cv::trace, cv::determinant, cv::repeat
etc.
matrix initializers (eye(), zeros(), ones()), matrix comma-separated initializers, matrix
constructors and operators that extract sub-matrices (see Mat description).§

Mat_<destination_type>() constructors to cast the result to the proper type.
Note, however, that comma-separated initializers and probably some other operations may require
additional explicit Mat() or Mat_<T>() constuctor calls to resolve possible ambiguity.

转载于:https://www.cnblogs.com/xiangwengao/archive/2012/03/20/2408110.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值