-
Notifications
You must be signed in to change notification settings - Fork 5
/
Img.java
66 lines (52 loc) · 1.52 KB
/
Img.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.genericsystem.cv;
import java.util.ArrayList;
import java.util.List;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
public class Img {
private final Mat src;
public Mat getSrc() {
return src;
}
public Img(Mat src) {
this.src = src.clone();
}
public Img sobel(int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType) {
Mat result = new Mat();
Imgproc.Sobel(src, result, ddepth, dx, dy, ksize, scale, delta, borderType);
return new Img(result);
}
public Img thresHold(double thresh, double maxval, int type) {
Mat result = new Mat();
Imgproc.threshold(src, result, thresh, maxval, type);
return new Img(result);
}
public Img morphologyEx(int morphClose, StructuringElement structuringElement) {
Mat result = new Mat();
Imgproc.morphologyEx(src, result, morphClose, structuringElement.getSrc());
return new Img(result);
}
public List<MatOfPoint> findContours(Img[] hierarchy, int mode, int method) {
Mat mat = new Mat();
List<MatOfPoint> result = new ArrayList<MatOfPoint>();
Imgproc.findContours(src, result, mat, mode, method);
hierarchy[0] = new Img(mat);
return result;
}
public Img canny(double threshold1, double threshold2) {
Mat result = new Mat();
Imgproc.Canny(src, result, threshold1, threshold2);
return new Img(result);
}
public Size size() {
return src.size();
}
public int height() {
return src.height();
}
public int width() {
return src.width();
}
}