1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
| #include <opencv2/opencv.hpp> #include <iostream>
using namespace cv; using namespace std;
int main() { Mat img_src; img_src = imread("chese.jpg", IMREAD_COLOR);
pyrDown(img_src, img_src);
int height = img_src.rows; int width = img_src.cols;
int w_q1 = width / 4; int h_q1 = height / 4; int w_q2 = width / 4; int h_q2 = width / 4;
Mat img_crop1, img_crop2; img_crop1 = img_src(Rect(30, 180, 200, 440)).clone(); img_crop2 = img_src(Rect(570, 320, 160, 280)).clone();
cvtColor(img_crop1, img_crop1, COLOR_BGR2GRAY); cvtColor(img_crop1, img_crop1, COLOR_GRAY2BGR);
cvtColor(img_crop2, img_crop2, COLOR_BGR2GRAY); cvtColor(img_crop2, img_crop2, COLOR_GRAY2BGR);
img_crop1.copyTo(img_src(Rect(30, 180, 200, 440))); img_crop2.copyTo(img_src(Rect(570, 320, 160, 280)));
imshow("crop", img_src); waitKey(); destroyAllWindows();
//Mat img_src; //img_src = imread("chese.jpg", IMREAD_COLOR); //int height = img_src.rows; //int width = img_src.cols;
//int w_q1 = width / 4; //int h_q1 = height / 4;
////img_crop = img_src[h_q1:h_q3, w_q1 : w_q3].copy() //Mat img_crop; //img_crop = img_src(Rect(w_q1, h_q1, width / 2, height / 2)).clone();
//cvtColor(img_crop, img_crop, COLOR_BGR2GRAY); //cvtColor(img_crop, img_crop, COLOR_GRAY2BGR);
//img_crop.copyTo(img_src(Rect(w_q1, h_q1, width / 2, height / 2)));
//imshow("src", img_src); //waitKey(); //destroyAllWindows();
/*Mat img_src;
img_src = imread("balloon.jpg", IMREAD_COLOR);
int height = img_src.rows; int width = img_src.cols;
Mat img_dst1; Mat img_dst2;
pyrDown(img_src, img_dst1); pyrUp(img_src, img_dst2, Size(width * 2, height * 2));
resize(img_src, img_dst1, Size(width, height), INTER_LINEAR); resize(img_src, img_dst2, Size(), 0.5, 0.5);
imshow("src", img_src); imshow("dst1", img_dst1); imshow("dst2", img_dst2); waitKey(); destroyAllWindows();*/
/*Mat img_src; img_src = imread("balloon.jpg", IMREAD_COLOR);
Mat img_dst; flip(img_src, img_dst, 1);
imshow("src", img_src); imshow("flip", img_dst);
waitKey(); destroyAllWindows();*/
//Mat img_src; //img_src = imread("balloon.jpg", IMREAD_COLOR); //int height = img_src.rows; //int width = img_src.cols;
//Mat matrix = getRotationMatrix2D( // Point(width / 2, height / 2), // 회전할 때 중심점 // 45, //회전 각도 // 1); // 이미지 배율
//Mat img_dst; //warpAffine(img_src, img_dst, matrix, Size(width, height));
//imshow("src", img_src); //imshow("rotation Result", img_dst); //waitKey(); //destroyAllWindows();
//Mat frame; //VideoCapture cap("aespa.mp4");
//if (!cap.isOpened()) //{ // cout << "동영상을 열 수 없습니다." << endl; // return -1; //}
//Mat frame_gray;
//while (1) //{ // bool ret = cap.read(frame); // frame 은 img_src 동일 // // 이미지 처리를 해주면 됨 // cvtColor(frame, frame_gray, COLOR_BGR2GRAY); // // // imshow("Video", frame); // imshow("Video-Gray", frame_gray); // // int key = waitKey(33);
// if (key == 27) // ESC 키 // break; //}
//cap.release();
//Mat img_src; //img_src = imread("balloon.jpg", IMREAD_COLOR);
//// 이미지를 그레이영상으로 바꿈 //Mat img_gray; //cvtColor(img_src, img_gray, COLOR_BGR2GRAY);
//imshow("Src", img_src); //imshow("Gray", img_gray);
//waitKey(0); //destroyAllWindows();
// cout << "OpenCV Version : " << CV_VERSION << endl; }
|