Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <string>
- #include "opencv/cv.h"
- #include "opencv/highgui.h"
- using namespace cv;
- using namespace std;
- int main(int argc, char **argv){
- // Kijk of er een filenaam is opgegeven.
- if (argc == 1) {
- cerr << "Gelieve een bestandsnaam op te geven." << endl;
- return 1;
- }
- // De file die we zullen inlezen.
- string filename = argv[1];
- Mat img = imread(filename, -1);
- printf("File ingelezen.");
- // Window aanmaken waar we de image in kunnen plaatsen.
- // Plaats de image op de window.
- namedWindow("myWindow", CV_WINDOW_AUTOSIZE );
- imshow("myWindow", img);
- waitKey(0);
- // Treshhold 50%
- // Note: 'opencv_imgproc' moet toegevoegd worden in CMakeList.txt bij
- // de OpenCV Libraries.
- Mat dst;
- threshold(img, dst, 50, 255, 0);
- imshow("myWindow", dst);
- waitKey(0);
- // Wegschrijven
- imwrite("threshed.png", dst);
- return 0;
- }
Add Comment
Please, Sign In to add comment