Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <cstdio>
  2. #include <string>
  3. #include "opencv/cv.h"
  4. #include "opencv/highgui.h"
  5.  
  6. using namespace cv;
  7. using namespace std;
  8.  
  9. int main(int argc, char **argv){
  10.         // Kijk of er een filenaam is opgegeven.
  11.         if (argc == 1) {
  12.             cerr << "Gelieve een bestandsnaam op te geven." << endl;
  13.             return 1;
  14.         }
  15.  
  16.         // De file die we zullen inlezen.
  17.         string filename = argv[1];
  18.         Mat img = imread(filename, -1);
  19.         printf("File ingelezen.");
  20.  
  21.         // Window aanmaken waar we de image in kunnen plaatsen.
  22.         // Plaats de image op de window.
  23.         namedWindow("myWindow", CV_WINDOW_AUTOSIZE );
  24.         imshow("myWindow", img);
  25.         waitKey(0);
  26.  
  27.         // Treshhold 50%
  28.         // Note: 'opencv_imgproc' moet toegevoegd worden in CMakeList.txt bij
  29.         // de OpenCV Libraries.
  30.         Mat dst;
  31.         threshold(img, dst, 50, 255, 0);
  32.         imshow("myWindow", dst);
  33.         waitKey(0);
  34.  
  35.         // Wegschrijven
  36.         imwrite("threshed.png", dst);
  37.     return 0;
  38. }
Add Comment
Please, Sign In to add comment