Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <opencv2/imgcodecs.hpp>
- #include <opencv2/highgui.hpp>
- #include <iostream>
- #include <opencv2/imgproc/imgproc.hpp>
- using namespace cv;
- using namespace std;
- int main(int argc, char** argv) {
- std::string fileName("testImage.jpg");
- if (argc > 1) {
- fileName = argv[1];
- }
- Mat image = imread(fileName, cv::IMREAD_COLOR);
- Mat grey_image, tresh, canny_output, contours, drawing;
- if (image.empty()) {
- std::cout << "Could not find or open the image." << std::endl;
- exit(-1);
- }
- else
- {
- //oryginal
- imshow("Oryginal image", image);
- //greay
- cv::cvtColor(image, grey_image, CV_BGR2GRAY);
- imshow("GreyScale image", grey_image);
- //treshold
- int threshold_value = 150;
- int threshold_type = 3;
- int const max_value = 255;
- int const max_BINARY_value = 255;
- threshold(grey_image, tresh, threshold_value, max_BINARY_value, threshold_type);
- imshow("Treshholding", tresh);
- //EDGES
- Canny(grey_image, canny_output, 100, 200, 3);
- imshow("Canny Edges", canny_output);
- }
- cv::waitKey(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement