Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void lab02() {
- // Beolvassuk a színes képet
- Mat im = imread("eper.jpg");
- Mat z(im.rows, im.cols, CV_8UC1, Scalar(0));
- Mat imBig = Mat(im.rows * 3, im.cols * 6, im.type());
- imBig.setTo(Scalar(128, 128, 255, 0));
- int index = 0;
- Mat result = im.clone();
- Mat bgr[3], & b = bgr[0], & g = bgr[1], & r = bgr[2];
- split(im, bgr);
- showMyImage(imBig, result, index);
- //1
- merge(vector<Mat>{z, g, r}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{b, z, r}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{b, g, z}, result);
- showMyImage(imBig, result, index);
- //2
- merge(vector<Mat>{b, z, z}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{z, g, z}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{z, z, r}, result);
- showMyImage(imBig, result, index);
- //3.
- result = im.clone();
- merge(vector<Mat>{b, g, r}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{b, r, g}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{g, b, r}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{g, r, b}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{r, b, g}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{r, g, b}, result);
- showMyImage(imBig, result, index);
- //4
- merge(vector<Mat>{~b,g,r}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{b, ~g, r}, result);
- showMyImage(imBig, result, index);
- merge(vector<Mat>{b, g, ~r}, result);
- showMyImage(imBig, result, index);
- //5
- cvtColor(im, result, COLOR_BGR2YCrCb);
- Mat yCrCb[3], &y = yCrCb[0], &Cr = yCrCb[1], &Cb = yCrCb[2];
- split(result,yCrCb);
- merge(vector<Mat>{~y, Cr, Cb}, result);
- cvtColor(result, result, COLOR_YCrCb2BGR);
- showMyImage(imBig, result, index);
- //6
- merge(vector<Mat>{~b, ~g, ~r}, result);
- showMyImage(imBig, result, index);
- waitKey(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement