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 package org.openimaj.image.feature.global;
31
32 import org.openimaj.citation.annotation.Reference;
33 import org.openimaj.citation.annotation.ReferenceType;
34 import org.openimaj.citation.annotation.References;
35 import org.openimaj.feature.DoubleFV;
36 import org.openimaj.feature.FeatureVectorProvider;
37 import org.openimaj.image.DisplayUtilities;
38 import org.openimaj.image.FImage;
39 import org.openimaj.image.analyser.ImageAnalyser;
40 import org.openimaj.image.processing.algorithm.FourierTransform;
41
42
43
44
45
46
47
48
49
50
51
52
53 @References(
54 references = {
55 @Reference(
56 type = ReferenceType.Inproceedings,
57 author = { "Ke, Yan", "Tang, Xiaoou", "Jing, Feng" },
58 title = "The Design of High-Level Features for Photo Quality Assessment",
59 year = "2006",
60 booktitle = "Proceedings of the 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition - Volume 1",
61 pages = { "419", "", "426" },
62 url = "http://dx.doi.org/10.1109/CVPR.2006.303",
63 publisher = "IEEE Computer Society",
64 series = "CVPR '06",
65 customData = {
66 "isbn", "0-7695-2597-0",
67 "numpages", "8",
68 "doi", "10.1109/CVPR.2006.303",
69 "acmid", "1153495",
70 "address", "Washington, DC, USA"
71 }
72 ),
73 @Reference(
74 type = ReferenceType.Inproceedings,
75 author = { "Che-Hua Yeh", "Yuan-Chen Ho", "Brian A. Barsky", "Ming Ouhyoung" },
76 title = "Personalized Photograph Ranking and Selection System",
77 year = "2010",
78 booktitle = "Proceedings of ACM Multimedia",
79 pages = { "211", "220" },
80 month = "October",
81 customData = { "location", "Florence, Italy" }
82 )
83 })
84 public class SharpPixelProportion implements ImageAnalyser<FImage>, FeatureVectorProvider<DoubleFV> {
85 double bpp = 0;
86 private float threshold = 2f;
87
88
89
90
91 public SharpPixelProportion() {
92 }
93
94
95
96
97
98
99
100 public SharpPixelProportion(float threshold) {
101 this.threshold = threshold;
102 }
103
104 @Override
105 public DoubleFV getFeatureVector() {
106 return new DoubleFV(new double[] { bpp });
107 }
108
109
110
111
112
113
114
115
116 @Override
117 public void analyseImage(FImage image) {
118 final FourierTransform ft = new FourierTransform(image, false);
119 final FImage mag = ft.getMagnitude();
120
121 int count = 0;
122 for (int y = 0; y < mag.height; y++) {
123 for (int x = 0; x < mag.width; x++) {
124 if (Math.abs(mag.pixels[y][x]) > threshold)
125 count++;
126 }
127 }
128 bpp = (double) count / (double) (mag.height * mag.width);
129
130 DisplayUtilities.display(image, "" + bpp);
131 }
132
133
134
135
136
137 public double getBlurredPixelProportion() {
138 return bpp;
139 }
140 }