-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathopencv.cc
More file actions
37 lines (24 loc) · 753 Bytes
/
opencv.cc
File metadata and controls
37 lines (24 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* compile with:
g++ -g -Wall opencv.cc `pkg-config opencv --cflags --libs`
code from Amadan@shacknews, thank you very much!
*/
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace cv;
int
main (int argc, char **argv)
{
Mat img = imread (argv[1]);
if (img.empty ())
return 1;
Mat crop = Mat (img, Rect (100, 100, img.cols - 200, img.rows - 200));
Mat shrunk;
resize (crop, shrunk, Size (0, 0), 0.9, 0.9);
float m[3][3] = { {-1, -1, -1}, {-1, 16, -1}, {-1, -1, -1} };
Mat kernel = Mat (3, 3, CV_32F, m) / 8.0;
Mat sharp;
filter2D (shrunk, sharp, -1, kernel, Point (-1, -1), 0, BORDER_REPLICATE);
imwrite (argv[2], sharp);
return 0;
}