Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of gr-peach-opencv-project-sd-card by
MatExpr Class Reference
[Basic structures]
Matrix expression representation. More...
#include <mat.hpp>
Related Functions | |
(Note that these are not member functions.) | |
CV_EXPORTS MatExpr | abs (const Mat &m) |
Calculates an absolute value of each matrix element. | |
CV_EXPORTS MatExpr | abs (const MatExpr &e) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Detailed Description
Matrix expression representation.
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 ), alpha for a real-valued scalar ( double )):
- Addition, subtraction, negation: `A+B`, `A-B`, `A+s`, `A-s`, `s+A`, `s-A`, `-A`
- Scaling: `A*alpha`
- Per-element multiplication and division: `A.mul(B)`, `A/B`, `alpha/A`
- Matrix multiplication: `A*B`
- Transposition: `A.t()` (means AT)
- Matrix inversion and pseudo-inversion, solving linear systems and least-squares problems: `A.inv([method]) (~ A-1)`, `A.inv([method])*B (~ X: AX=B)`
- Comparison: `A cmpop B`, `A cmpop alpha`, `alpha cmpop A`, where *cmpop* is one of `>`, `>=`, `==`, `!=`, `<=`, `<`. The result of comparison is an 8-bit single channel mask whose elements are set to 255 (if the particular element or pair of elements satisfy the condition) or 0.
- Bitwise logical operations: `A logicop B`, `A logicop s`, `s logicop A`, `~A`, where *logicop* is one of `&`, `|`, `^`.
- Element-wise minimum and maximum: `min(A, B)`, `min(A, alpha)`, `max(A, B)`, `max(A, alpha)`
- 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 norm, mean, sum, countNonZero, trace, determinant, repeat, and others.
- Matrix initializers ( Mat::eye(), Mat::zeros(), Mat::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:
- Comma-separated initializers and probably some other operations may require additional explicit Mat() or Mat_<T>() constructor calls to resolve a possible ambiguity.
// compute pseudo-inverse of A, equivalent to A.inv(DECOMP_SVD) SVD svd(A); Mat pinvA = svd.vt.t()*Mat::diag(1./svd.w)*svd.u.t(); // compute the new vector of parameters in the Levenberg-Marquardt algorithm x -= (A.t()*A + lambda*Mat::eye(A.cols,A.cols,A.type())).inv(DECOMP_CHOLESKY)*(A.t()*err); // sharpen image using "unsharp mask" algorithm Mat blurred; double sigma = 1, threshold = 5, amount = 1; GaussianBlur(img, blurred, Size(), sigma, sigma); Mat lowContrastMask = abs(img - blurred) < threshold; Mat sharpened = img*(1+amount) + blurred*(-amount); img.copyTo(sharpened, lowContrastMask);
Definition at line 3281 of file mat.hpp.
Friends And Related Function Documentation
Calculates an absolute value of each matrix element.
abs is a meta-function that is expanded to one of absdiff or convertScaleAbs forms:
- C = abs(A-B) is equivalent to `absdiff(A, B, C)`
- C = abs(A) is equivalent to `absdiff(A, Scalar::all(0), C)`
- C = `Mat_<Vec<uchar,n> >(abs(A*alpha + beta))` is equivalent to `convertScaleAbs(A, C, alpha, beta)`
The output matrix has the same size and the same type as the input one except for the last case, where C is depth=CV_8U .
- Parameters:
-
m matrix.
- See also:
- MatrixExpressions, absdiff, convertScaleAbs
Generated on Tue Jul 12 2022 14:48:00 by
