Ask Your Question

Revision history [back]

image description the key of the problem is "set the roi"

 Mat matSrc = imread("e:/template/lena.jpg");  
    Mat matGray ; 
cvtColor(matSrc,matGray,COLOR_BGR2GRAY);
cvtColor(matGray,matGray,COLOR_GRAY2BGR);

Mat matDst(Size(matSrc.cols*2,matSrc.rows),matSrc.type(),Scalar::all(0));
Mat matRoi = matDst(Rect(0,0,matSrc.cols,matSrc.rows));
matSrc.copyTo(matRoi);
matRoi = matDst(Rect(matSrc.cols,0,matSrc.cols,matSrc.rows));
matGray.copyTo(matRoi);

imshow("result",matSrc);
waitKey(0);
return;