Mat image = imread("image.jpg"); int rows = image.rows; cout << "Number of rows: " << rows << endl;
Mat matrix = Mat::ones(4, 4, CV_32F); for (int i = 0; i < matrix.rows; ++i) { cout << "Row " << i << ": "; for (int j = 0; j < matrix.cols; ++j) { cout << matrix.atExplanation: This code creates a 4x4 matrix with all values initialized to 1 using the `ones` function. Then, a loop is executed to iterate through each row of the matrix. Within the loop, another loop is executed to iterate through each column in the row. The `at` function is used to access specific elements of the matrix, and finally, the elements of each row are printed to the console. Package library: OpenCV(i, j) << " "; } cout << endl; }