#include #include #include #include #include using namespace std; using namespace cv; //string image_file = "C:\\Users\\patrik\\Downloads\\kaiser-wilhelm-2176402_640.jpg"; string image_file = "C:\\Users\\patrik\\Downloads\\1489872650_girl.png"; int main() { Mat img = imread(image_file); /*imshow("okno", img); Vec3b bod = img.at(0, 0); cout << bod << endl; waitKey(0);*/ /* float a = 1.2; float b = 50; // TODO: preco to nejde jas a kontras na kazdom bode for (int y = 0; y < img.rows; y++) { Vec3b* row = img.ptr(y); for (int x = 0; x < img.cols; x++) { Vec3b color = row[x]; row[x] = Vec3b(255 - color[0], 255 - color[1], 255 - color[2]); } } img *= a; img += b; imshow("okno", img); waitKey(0); imwrite("upraveny_jas.jpg", img);*/ Mat parts[3]; split(img, parts); /* imshow("okno", parts[0]); waitKey(0); imshow("okno", parts[1]); waitKey(0); imshow("okno", parts[2]); waitKey(0); Mat parts1[] = { parts[2] , parts[1] , parts[0] }; Mat output; merge(parts1, 3, output); imshow("okno2", output); waitKey(0); */ Mat gray; cvtColor(img, gray, ColorConversionCodes::COLOR_BGR2GRAY); imshow("okno2", gray); waitKey(0); Mat output, mask; /*mask = (Mat_(3, 3) << 1, 1, 1, 1, 1, 1, 1, 1, 1); mask *= (1.f / 9); filter2D(Mat_(gray), output, -1, mask); imshow("okno3", Mat_(output)); waitKey(0); mask = (Mat_(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0); filter2D(Mat_(gray), output, -1, mask); imshow("okno4", Mat_(output)); waitKey(0);*/ /* mask = (Mat_(3, 3) << 1, 1, 1, 1, -8, 1, 1, 1, 1); filter2D(Mat_(gray), output, -1, mask); imshow("okno5", Mat_(output)); waitKey(0); Laplacian(gray, output, -1); imshow("laplace", output); waitKey(0); imshow("laplace trehs", output > 127); Canny(gray, output, 180, 230); imshow("canny", output); waitKey(0); */ Mat maska = gray < 230; imshow("maska", maska); waitKey(0); img.copyTo(output, maska); imshow("maska", output); waitKey(0); return 0; }