-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTransparencyVisualizer.java
More file actions
110 lines (108 loc) · 4.17 KB
/
TransparencyVisualizer.java
File metadata and controls
110 lines (108 loc) · 4.17 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Part of SourceAFIS Visualization: https://sourceafis.machinezoo.com/transparency/
package com.machinezoo.sourceafis.visualization;
import java.util.*;
import com.machinezoo.sourceafis.transparency.*;
import com.machinezoo.sourceafis.transparency.keys.*;
import com.machinezoo.sourceafis.transparency.types.*;
import com.machinezoo.sourceafis.visualization.keys.*;
import com.machinezoo.sourceafis.visualization.utils.*;
import com.machinezoo.stagean.*;
import one.util.streamex.*;
public interface TransparencyVisualizer {
TransparencyKey<?> key();
/*
* Just preferred operation. All relevant operations can be found on the key.
*/
default TransparentOperation operation() {
return key().operation();
}
/*
* Specifying MIME/extension on visualizer in addition to specifying it on generated visualization is a tradeoff.
* Calling code can know upfront what output to expect, but visualizers lose freedom to switch MIME based on content.
* This hardcoding of output type also manifests in specialized visualizer interfaces.
* Fortunately, visualizers are specialized enough to know their output type with certainty.
* Switching MIME type is possible only in some degenerate cases when optional dependencies are missing
* and output is consequently greatly simplified. These corner cases are not worth the effort and complexity.
*/
String mime();
default String extension() {
return ImageMime.extension(mime());
}
/*
* List of keys this visualizer can potentially use. Some of these are optional.
* Some keys are operation-specific. Callers can filter them by looking at key operations.
*/
default Set<TransparencyKey<?>> dependencies() {
return Set.of(key());
}
default Set<TransparencyKey<?>> dependencies(TransparentOperation operation) {
return StreamEx.of(dependencies())
.filter(k -> k.operations().contains(operation))
.toSet();
}
/*
* Like dependencies, but only required keys are listed.
* This may still contain keys that are applicable only to some operations.
* Key are really required only after filtering by operation.
*/
default Set<TransparencyKey<?>> required() {
return StreamEx.of(dependencies())
.filter(k -> !(k instanceof SideImageKey) && !(k instanceof SideGrayscaleKey))
.toSet();
}
default Set<TransparencyKey<?>> required(TransparentOperation operation) {
return StreamEx.of(required())
.filter(k -> k.operations().contains(operation))
.toSet();
}
@DraftApi("Allow visualizing pairing/scoring other than the first one.")
TransparencyImage visualize(TransparencyArchive archive);
static List<TransparencyVisualizer> all() {
var all = new ArrayList<TransparencyVisualizer>();
all.addAll(List.of(
new DecodedImageVisualizer(),
new ScaledImageVisualizer(),
new BlocksVisualizer(),
new HistogramVisualizer(),
new SmoothedHistogramVisualizer(),
new ContrastVisualizer(),
new AbsoluteContrastMaskVisualizer(),
new RelativeContrastMaskVisualizer(),
new CombinedMaskVisualizer(),
new FilteredMaskVisualizer(),
new EqualizedImageVisualizer(),
new PixelwiseOrientationVisualizer(),
new BlockOrientationVisualizer(),
new SmoothedOrientationVisualizer(),
new ParallelSmoothingVisualizer(),
new OrthogonalSmoothingVisualizer(),
new BinarizedImageVisualizer(),
new FilteredBinaryImageVisualizer(),
new PixelMaskVisualizer(),
new InnerMaskVisualizer()));
for (var skeleton : SkeletonType.values()) {
all.addAll(List.of(
new BinarizedSkeletonVisualizer(skeleton),
new ThinnedSkeletonVisualizer(skeleton),
new TracedSkeletonVisualizer(skeleton),
new RemovedDotsVisualizer(skeleton),
new RemovedPoresVisualizer(skeleton),
new RemovedGapsVisualizer(skeleton),
new RemovedTailsVisualizer(skeleton),
new RemovedFragmentsVisualizer(skeleton)));
}
all.addAll(List.of(
new SkeletonMinutiaeVisualizer(),
new InnerMinutiaeVisualizer(),
new RemovedMinutiaCloudsVisualizer(),
new TopMinutiaeVisualizer(),
new ShuffledMinutiaeVisualizer(),
new EdgeTableVisualizer(),
new OutputTemplateVisualizer(),
new EdgeHashVisualizer(),
new RootsVisualizer(),
new PairingVisualizer(),
new BestPairingVisualizer()));
return Collections.unmodifiableList(all);
}
}