
matrix expression, it will be evaluated and a pointer to the results will be assigned in m2. The results will
reside in a newly allocated data area.
22
Table 3-17 lists examples of the algebraic operations available. Note that in addition to simple algebra,
there are comparison operators, operators for constructing matrices (such as cv::Mat::eye(), which
we encountered earlier), and higher level operations for computing transposes and inversions. The key idea
here is that you should be able to take the sorts of relatively nontrivial matrix expressions that occur when
doing computer vision and express them on a single line in a clear and concise way.
Table 3-17: Operations available for matrix expressions
Addition or subtraction of matrices
m0 + s; m0 – s; s + m0, s – m1;
Addition or subtraction between a matrix
and a singleton
Scaling of a matrix by a singleton
Per element multiplication of m0 and m1,
per-element division of m0 by m1
Matrix multiplication of m0 and m1
Matrix inversion of m0 (default value of
method is DECOMP_LU)
Matrix transpose of m0 (no copy is done)
m0>m1; m0>=m1; m0==m1; m0<=m1; m0<m1;
Per element comparison, returns uchar
matrix with elements 0 or 255
m0&m1; m0|m1; m0^m1; ~m0;
m0&s; s&m0; m0|s; s|m0 ...