-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathImageProcessing.java
More file actions
75 lines (66 loc) · 2.6 KB
/
Copy pathImageProcessing.java
File metadata and controls
75 lines (66 loc) · 2.6 KB
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
67
68
69
70
71
72
73
74
75
package jdip;
import com.jhlabs.image.*;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.util.Vector;
class ImageProcessing {
private static Vector<BufferedImageOp> filters;
private static Vector<BufferedImageOp> transformations;
private static Vector<BufferedImageOp> morphs;
static Vector<BufferedImageOp> getFilters() {
if (filters == null) {
filters = new Vector<>();
filters.add(new BlurFilter());
filters.add(new EdgeFilter());
filters.add(new InvertFilter());
filters.add(new PosterizeFilter());
filters.add(new SharpenFilter());
filters.add(new GaussianFilter());
filters.add(new ChromeFilter());
filters.add(new CrystallizeFilter());
filters.add(new MedianFilter());
filters.add(new MaximumFilter());
filters.add(new EqualizeFilter());
filters.add(new OilFilter());
filters.add(new LevelsFilter());
filters.add(new ThresholdFilter(64));
filters.add(new ThresholdFilter(128));
filters.add(new ThresholdFilter(192));
}
return filters;
}
static Vector<BufferedImageOp> getTransformations() {
if (transformations == null) {
transformations = new Vector<>();
transformations.add(new RotateFilter(
(float) Math.PI / 6));
transformations.add(new RotateFilter(
(float) Math.PI / 3));
transformations.add(new RotateFilter(
(float) Math.PI / 2));
transformations.add(
new RotateFilter((float) Math.PI));
transformations.add(new ScaleFilter());
transformations.add(new ScaleFilter(16, 16));
transformations.add(new ScaleFilter(8, 16));
}
return transformations;
}
static Vector<BufferedImageOp> getMorphs() {
if (morphs == null) {
morphs = new Vector<>();
morphs.add(createShearFilter((float) Math.PI / 6, (float) Math.PI / 3));
morphs.add(createShearFilter((float) Math.PI / 2, (float) Math.PI / 4));
}
return morphs;
}
private static BufferedImageOp createShearFilter(float xAngle, float yAngle) {
ShearFilter sf = new ShearFilter();
sf.setXAngle(xAngle);
sf.setXAngle(yAngle);
return sf;
}
static BufferedImage process(BufferedImage mBufferedImage, BufferedImageOp operation) {
return operation.filter(mBufferedImage, null);
}
}