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.feature.DoubleFV;
35 import org.openimaj.feature.FeatureVectorProvider;
36 import org.openimaj.image.FImage;
37 import org.openimaj.image.MBFImage;
38 import org.openimaj.image.analyser.ImageAnalyser;
39 import org.openimaj.image.colour.Transforms;
40 import org.openimaj.image.pixel.statistics.MaskingHistogramModel;
41 import org.openimaj.image.saliency.DepthOfFieldEstimator;
42 import org.openimaj.image.saliency.LuoTangSubjectRegion;
43 import org.openimaj.math.statistics.distribution.MultidimensionalHistogram;
44
45
46
47
48
49
50
51 @Reference(
52 type = ReferenceType.Inproceedings,
53 author = { "Luo, Yiwen", "Tang, Xiaoou" },
54 title = "Photo and Video Quality Evaluation: Focusing on the Subject",
55 year = "2008",
56 booktitle = "Proceedings of the 10th European Conference on Computer Vision: Part III",
57 pages = { "386", "399" },
58 url = "http://dx.doi.org/10.1007/978-3-540-88690-7_29",
59 publisher = "Springer-Verlag",
60 series = "ECCV '08",
61 customData = {
62 "isbn", "978-3-540-88689-1",
63 "location", "Marseille, France",
64 "numpages", "14",
65 "doi", "10.1007/978-3-540-88690-7_29",
66 "acmid", "1478204",
67 "address", "Berlin, Heidelberg"
68 })
69 public class LuoSimplicity implements ImageAnalyser<MBFImage>, FeatureVectorProvider<DoubleFV> {
70 LuoTangSubjectRegion extractor;
71 int binsPerBand = 16;
72 float gamma = 0.01f;
73 double simplicity;
74
75
76
77
78
79
80 public LuoSimplicity() {
81 extractor = new LuoTangSubjectRegion();
82 }
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 public LuoSimplicity(int binsPerBand, float gamma, float alpha, int maxKernelSize, int kernelSizeStep, int nbins,
103 int windowSize)
104 {
105 extractor = new LuoTangSubjectRegion(alpha, maxKernelSize, kernelSizeStep, nbins, windowSize);
106 this.binsPerBand = binsPerBand;
107 this.gamma = gamma;
108 }
109
110 @Override
111 public void analyseImage(MBFImage image) {
112 Transforms.calculateIntensityNTSC(image).analyseWith(extractor);
113 final FImage mask = extractor.getROIMap().inverse();
114
115 final MaskingHistogramModel hm = new MaskingHistogramModel(mask, binsPerBand, binsPerBand, binsPerBand);
116 hm.estimateModel(image);
117
118 final MultidimensionalHistogram fv = hm.getFeatureVector();
119 final double thresh = gamma * fv.max();
120 int count = 0;
121 for (final double f : fv.values) {
122 if (f >= thresh)
123 count++;
124 }
125
126 simplicity = (double) count / (double) fv.values.length;
127 }
128
129 @Override
130 public DoubleFV getFeatureVector() {
131 return new DoubleFV(new double[] { simplicity });
132 }
133 }