Advertisement
tankian202

Untitled

Oct 10th, 2023 (edited)
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. void lab02() {
  2.     // Beolvassuk a színes képet
  3.     Mat im = imread("eper.jpg");
  4.     Mat z(im.rows, im.cols, CV_8UC1, Scalar(0));
  5.     Mat imBig = Mat(im.rows * 3, im.cols * 6, im.type());
  6.     imBig.setTo(Scalar(128, 128, 255, 0));
  7.     int index = 0;
  8.     Mat result = im.clone();
  9.    
  10.     Mat bgr[3], & b = bgr[0], & g = bgr[1], & r = bgr[2];
  11.     split(im, bgr);
  12.     showMyImage(imBig, result, index);
  13.     //1
  14.     merge(vector<Mat>{z, g, r}, result);
  15.     showMyImage(imBig, result, index);
  16.     merge(vector<Mat>{b, z, r}, result);
  17.     showMyImage(imBig, result, index);
  18.     merge(vector<Mat>{b, g, z}, result);
  19.     showMyImage(imBig, result, index);
  20.     //2
  21.     merge(vector<Mat>{b, z, z}, result);
  22.     showMyImage(imBig, result, index);
  23.     merge(vector<Mat>{z, g, z}, result);
  24.     showMyImage(imBig, result, index);
  25.     merge(vector<Mat>{z, z, r}, result);
  26.     showMyImage(imBig, result, index);
  27.     //3.
  28.     result = im.clone();
  29.     merge(vector<Mat>{b, g, r}, result);
  30.     showMyImage(imBig, result, index);
  31.     merge(vector<Mat>{b, r, g}, result);
  32.     showMyImage(imBig, result, index);
  33.     merge(vector<Mat>{g, b, r}, result);
  34.     showMyImage(imBig, result, index);
  35.     merge(vector<Mat>{g, r, b}, result);
  36.     showMyImage(imBig, result, index);
  37.     merge(vector<Mat>{r, b, g}, result);
  38.     showMyImage(imBig, result, index);
  39.     merge(vector<Mat>{r, g, b}, result);
  40.     showMyImage(imBig, result, index);
  41.     //4
  42.     merge(vector<Mat>{~b,g,r}, result);
  43.     showMyImage(imBig, result, index);
  44.     merge(vector<Mat>{b, ~g, r}, result);
  45.     showMyImage(imBig, result, index);
  46.     merge(vector<Mat>{b, g, ~r}, result);
  47.     showMyImage(imBig, result, index);
  48.     //5
  49.     cvtColor(im, result, COLOR_BGR2YCrCb);
  50.     Mat yCrCb[3], &y = yCrCb[0], &Cr = yCrCb[1], &Cb = yCrCb[2];
  51.     split(result,yCrCb);
  52.     merge(vector<Mat>{~y, Cr, Cb}, result);
  53.     cvtColor(result, result, COLOR_YCrCb2BGR);
  54.     showMyImage(imBig, result, index);
  55.     //6
  56.     merge(vector<Mat>{~b, ~g, ~r}, result);
  57.     showMyImage(imBig, result, index);
  58.  
  59.     waitKey(0);
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement