-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
51 lines (41 loc) · 1.43 KB
/
main.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Created by shiyu on 2/17/20.
//
#include <iostream>
#include <string>
#include <ImgMat.h>
#include <ImgProc.h>
using namespace std;
using namespace cv;
int main(int argc, char **argv) {
if (argc != 2) {
printf("usage: ./ImgLibrary <Image_Path>\n");
return -1;
}
/** original input */
ImgMat imgMat;
imgMat.loadImg(argv[1], "RGB");
cout << "Height: " << imgMat.getHeight() << " Width: "
<< imgMat.getWidth() << " Type: " << imgMat.getType() << endl;
ImgProc::Display(imgMat, "input");
/** RGB to Gray */
ImgMat gray(imgMat.getHeight(), imgMat.getWidth(), "GrayScale");
ImgProc::RGB2Gray(imgMat, gray);
ImgProc::Display(gray, "input (grayscale converted)");
/** shallow copy of gray, shallow copy won't become the owner in this case*/
ImgMat sCopy(gray);
/** deep copy of gray*/
ImgMat dCopy;
gray.copyTo(dCopy);
/** apply some mask to gray at the center*/
ImgProc::CenterMask(gray, min(gray.getHeight(), gray.getWidth()) / 2);
ImgProc::Display(gray, "masked gray");
/** check if shallow/deep copy is touched */
ImgProc::Display(dCopy, "deep copy of gray (untouched)");
ImgProc::Display(sCopy, "shallow copy of gray (affected)");
cout << "number of shallow copy of the ori image: " << sCopy.useCount() << endl;
/** compute histogram */
auto hist = ImgProc::ComputeHistogram(imgMat);
cout << "size of histogram (" << hist.size() << ", " << hist[0].size() << ")" << endl;
return 0;
}