Last active
March 30, 2017 07:50
-
-
Save ppatrik/fa0b36bcf0a6836a438e8fbc4c7af0a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <opencv2\core.hpp> | |
| #include <opencv2\imgcodecs.hpp> | |
| #include <opencv2\imgproc.hpp> | |
| #include <opencv2\highgui.hpp> | |
| 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<Vec3b>(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<Vec3b>(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_<float>(3, 3) << 1, 1, 1, 1, 1, 1, 1, 1, 1); | |
| mask *= (1.f / 9); | |
| filter2D(Mat_<float>(gray), output, -1, mask); | |
| imshow("okno3", Mat_<uchar>(output)); | |
| waitKey(0); | |
| mask = (Mat_<float>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0); | |
| filter2D(Mat_<float>(gray), output, -1, mask); | |
| imshow("okno4", Mat_<uchar>(output)); | |
| waitKey(0);*/ | |
| /* | |
| mask = (Mat_<float>(3, 3) << 1, 1, 1, 1, -8, 1, 1, 1, 1); | |
| filter2D(Mat_<float>(gray), output, -1, mask); | |
| imshow("okno5", Mat_<uchar>(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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment