Mat.ones constructor

Mat.ones(
  1. int rows,
  2. int cols,
  3. MatType type
)

Returns an array of all 1's of the specified size and type.

The method returns a Matlab-style 1's array initializer, similarly to Mat::zeros. Note that using this method you can initialize an array with an arbitrary value, using the following Matlab idiom: Mat A = Mat::ones(100, 100, CV_8U)*3; // make 100x100 matrix filled with 3.

The above operation does not form a 100x100 matrix of 1's and then multiply it by 3. Instead, it just remembers the scale factor (3 in this case) and use it when actually invoking the matrix initializer.

Note In case of multi-channels type, only the first channel will be initialized with 1's, the others will be set to 0's.

rows Number of rows.

cols Number of columns.

type Created matrix type.

https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a5e10227b777425407986727e2d26fcdc

Implementation

factory Mat.ones(int rows, int cols, MatType type) {
  final p = calloc<cvg.Mat>();
  cvRun(() => ccore.cv_Mat_ones(rows, cols, type.value, p, ffi.nullptr));
  final mat = Mat._(p);
  return mat;
}