Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <opencv2/imgcodecs.hpp>
  2. #include <opencv2/highgui.hpp>
  3. #include <iostream>
  4. #include <opencv2/imgproc/imgproc.hpp>
  5.  
  6. using namespace cv;
  7. using namespace std;
  8.  
  9.  
  10. int main(int argc, char** argv) {
  11. std::string fileName("testImage.jpg");
  12.  
  13. if (argc > 1) {
  14. fileName = argv[1];
  15. }
  16.  
  17. Mat image = imread(fileName, cv::IMREAD_COLOR);
  18.  
  19. Mat grey_image, tresh, canny_output, contours, drawing;
  20.  
  21. if (image.empty()) {
  22. std::cout << "Could not find or open the image." << std::endl;
  23. exit(-1);
  24. }
  25. else
  26. {
  27. //oryginal
  28. imshow("Oryginal image", image);
  29.  
  30. //greay
  31. cv::cvtColor(image, grey_image, CV_BGR2GRAY);
  32. imshow("GreyScale image", grey_image);
  33.  
  34. //treshold
  35. int threshold_value = 150;
  36. int threshold_type = 3;
  37. int const max_value = 255;
  38. int const max_BINARY_value = 255;
  39. threshold(grey_image, tresh, threshold_value, max_BINARY_value, threshold_type);
  40. imshow("Treshholding", tresh);
  41.  
  42. //EDGES
  43. Canny(grey_image, canny_output, 100, 200, 3);
  44. imshow("Canny Edges", canny_output);
  45. }
  46.  
  47.  
  48. cv::waitKey(0);
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement