[][src]Function opencv::core::set_identity

pub fn set_identity(mtx: &mut dyn ToInputOutputArray, s: Scalar) -> Result<()>

Initializes a scaled identity matrix.

The function cv::setIdentity initializes a scaled identity matrix: block formula

The function can also be emulated using the matrix initializers and the matrix expressions:

This example is not tested
Mat A = Mat::eye(4, 3, CV_32F)*5;
// A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]

Parameters

  • mtx: matrix to initialize (not necessarily square).
  • s: value to assign to diagonal elements.

See also

Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=

C++ default parameters

  • s: Scalar(1)