Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void lab03() {
- float numbers[9] = { 0, 0,0,1,0,0,0,0,0 };
- Mat mask = Mat(3, 3, CV_32FC1, numbers);
- Mat im = imread("eper.jpg");
- Mat result = im.clone();
- int key = 0;
- for (int i = 0; (i < im.cols) && key != 27; i++)
- {
- filter2D(result, result, -1, mask);
- imshow("Result", result);
- key = waitKey();
- }
- float numbers2[9] = {0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.1};
- Mat mask2 = Mat(3, 3, CV_32FC1, numbers2);
- result = im.clone();
- key = 0;
- for (int i = 0; (i < im.cols) && key != 27; i++)
- {
- filter2D(result, result, -1, mask2);
- imshow("Result", result);
- key = waitKey();
- }
- im = imread("faliszonyeg.jpg");
- float k = 0;
- key = 0;
- result = im.clone();
- for (int i = 0; (i < im.cols) && key != 27; i++)
- {
- float numbers[9] = { 0, k / 4, 0, -k / 4, 1 + k, -k / 4, 0, -k / 4, 0 };
- Mat mask = Mat(3, 3, CV_32FC1, numbers);
- filter2D(result, result, -1, mask );
- imshow("Result", result);
- key = waitKey();
- k++;
- }
- key = 0;
- im = imread("eper.jpg");
- destroyWindow("Result");
- for (int k = 3; (k < 100) && key != 27;k += 2)
- {
- Mat resultGauss, resultBlur;
- blur(im, resultBlur,Size(k,k));
- GaussianBlur(im, resultGauss, Size(k, k), 1);
- imshow("Gauss", resultGauss);
- key = waitKey();
- imshow("Blur", resultBlur);
- key = waitKey();
- }
- Mat imBe = imread("repulo.jpg");
- Mat imKi = imBe.clone();
- key = 0;
- for (int db = 0; db < 20 ; ++db) {
- line(imBe, Point(rand() % imBe.cols, rand() % imBe.rows),
- Point(rand() % imBe.cols, rand() % imBe.rows),
- Scalar(0, 0, 0, 0), 1 + db % 2);
- Mat imKi = imBe.clone();
- }
- destroyAllWindows();
- for (int i = 1; i < 10 && key != 27; i+=2)
- {
- medianBlur(imBe, imKi, i);
- imshow("Result", imKi);
- key = waitKey(0);
- }
- destroyAllWindows();
- imBe = imread("amoba.png");
- key = 0;
- for (int i = 0;i < 600 && key!=27;i++)
- {
- medianBlur(imBe, imBe, 21);
- if(i%3==0){
- imshow("result", imBe);
- key = waitKey(0);
- }
- }
- }
- 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