#include#include int main() { // Create a 3x3 matrix cv::Mat originalMat(3, 3, CV_32SC1); for (int i = 0; i < 9; i++) { originalMat.at (i/3, i%3) = i + 1; } // Clone the matrix cv::Mat clonedMat = originalMat.clone(); // Print the clone std::cout << "Cloned matrix:\n" << clonedMat << std::endl; return 0; }
#include#include int main() { // Read in an image cv::Mat image = cv::imread("image.jpg"); // Convert the image to grayscale cv::Mat gray; cv::cvtColor(image, gray, cv::COLOR_BGR2GRAY); // Clone the grayscale matrix cv::Mat clonedGray = gray.clone(); // Display the original and the clone side by side cv::Mat display(2*image.rows, image.cols, image.type()); image.copyTo(display(cv::Rect(0, 0, image.cols, image.rows))); clonedGray.copyTo(display(cv::Rect(0, image.rows, image.cols, image.rows))); cv::imshow("Original and Clone", display); cv::waitKey(0); return 0; }