[−][src]Struct opencv::core::MatExpr
Matrix expression representation @anchor MatrixExpressions 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<sup>-1</sup>)
,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
- 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_
Here are examples of matrix expressions:
ⓘThis example is not tested
// 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);
Implementations
impl MatExpr
[src]
pub fn as_raw_MatExpr(&self) -> *const c_void
[src]
pub fn as_raw_mut_MatExpr(&mut self) -> *mut c_void
[src]
impl MatExpr
[src]
pub fn default() -> Result<MatExpr>
[src]
pub fn from_mat(m: &Mat) -> Result<MatExpr>
[src]
pub fn new(
_op: &dyn MatOp,
_flags: i32,
_a: &Mat,
_b: &Mat,
_c: &Mat,
_alpha: f64,
_beta: f64,
_s: Scalar
) -> Result<MatExpr>
[src]
_op: &dyn MatOp,
_flags: i32,
_a: &Mat,
_b: &Mat,
_c: &Mat,
_alpha: f64,
_beta: f64,
_s: Scalar
) -> Result<MatExpr>
C++ default parameters
- _a: Mat()
- _b: Mat()
- _c: Mat()
- _alpha: 1
- _beta: 1
- _s: Scalar()
Trait Implementations
impl Boxed for MatExpr
[src]
unsafe fn from_raw(ptr: *mut c_void) -> Self
[src]
fn into_raw(self) -> *mut c_void
[src]
fn as_raw(&self) -> *const c_void
[src]
fn as_raw_mut(&mut self) -> *mut c_void
[src]
impl Drop for MatExpr
[src]
impl MatExprTrait for MatExpr
[src]
fn as_raw_MatExpr(&self) -> *const c_void
[src]
fn as_raw_mut_MatExpr(&mut self) -> *mut c_void
[src]
fn flags(&self) -> i32
[src]
fn set_flags(&mut self, val: i32)
[src]
fn a(&mut self) -> Mat
[src]
fn set_a(&mut self, val: Mat)
[src]
fn b(&mut self) -> Mat
[src]
fn set_b(&mut self, val: Mat)
[src]
fn c(&mut self) -> Mat
[src]
fn set_c(&mut self, val: Mat)
[src]
fn alpha(&self) -> f64
[src]
fn set_alpha(&mut self, val: f64)
[src]
fn beta(&self) -> f64
[src]
fn set_beta(&mut self, val: f64)
[src]
fn s(&self) -> Scalar
[src]
fn set_s(&mut self, val: Scalar)
[src]
fn to_mat(&self) -> Result<Mat>
[src]
fn size(&self) -> Result<Size>
[src]
fn typ(&self) -> Result<i32>
[src]
fn row(&self, y: i32) -> Result<MatExpr>
[src]
fn col(&self, x: i32) -> Result<MatExpr>
[src]
fn diag(&self, d: i32) -> Result<MatExpr>
[src]
fn t(&self) -> Result<MatExpr>
[src]
fn inv(&self, method: i32) -> Result<MatExpr>
[src]
fn mul_matexpr(&self, e: &MatExpr, scale: f64) -> Result<MatExpr>
[src]
fn mul(&self, m: &Mat, scale: f64) -> Result<MatExpr>
[src]
fn cross(&self, m: &Mat) -> Result<Mat>
[src]
fn dot(&self, m: &Mat) -> Result<f64>
[src]
fn swap(&mut self, b: &mut MatExpr) -> Result<()>
[src]
impl Send for MatExpr
[src]
impl ToInputArray for MatExpr
[src]
fn input_array(&self) -> Result<_InputArray>
[src]
impl<'_> ToInputArray for &'_ MatExpr
[src]
fn input_array(&self) -> Result<_InputArray>
[src]
Auto Trait Implementations
impl RefUnwindSafe for MatExpr
impl !Sync for MatExpr
impl Unpin for MatExpr
impl UnwindSafe for MatExpr
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,