Transpiled version (13760L) is out of date.
1 | // A is the user object associated with each mask (aka a "label") |
2 | sclass G22MasksHolder<A> { |
3 | record noeq Mask(Image2B image, A label) { |
4 | } |
5 | |
6 | settable WidthAndHeight maskSize; |
7 | new L<Mask> masks; |
8 | new Set<A> labels; |
9 | |
10 | // default mask size |
11 | { maskSize(16); } |
12 | |
13 | selfType maskSize(int size) { |
14 | ret maskSize(widthAndHeight(size)); |
15 | } |
16 | |
17 | Image2B regionToMaskImage(IImageRegion region) { |
18 | ret toImage2B(scaledIBinaryImage(maskSize, regionToIBinaryImage(region))); |
19 | } |
20 | |
21 | void addRegion(IImageRegion region, A label) { |
22 | masks.add(new Mask(regionToMaskImage(region), label)); |
23 | ghost_cache = null; |
24 | certainty_cache = null; |
25 | labels.add(label); |
26 | } |
27 | |
28 | L<Image2B> maskImages() { |
29 | ret map(masks, mask -> mask.image); |
30 | } |
31 | |
32 | BufferedImage masksSquare() { |
33 | ret mergeBufferedImagesAsSquare(allToBufferedImage(maskImages())); |
34 | } |
35 | |
36 | toString { |
37 | ret renderVars(shortClassName(this), |
38 | +maskSize, |
39 | masks := n2(masks), |
40 | +certainty()); |
41 | } |
42 | |
43 | simplyCached FloatBWImage ghost() { |
44 | ret preciseAverageOfBinaryImages(maskImages()); |
45 | } |
46 | |
47 | simplyCached double certainty() { |
48 | ret preciseCertaintyImage(ghost()).averageBrightness(); |
49 | } |
50 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035842 |
Snippet name: | G22MasksHolder (old) |
Eternal ID of this version: | #1035842/17 |
Text MD5: | c60d082063fd3a8f734ff0a8457836e6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-05 15:50:01 |
Source code size: | 1231 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 148 / 267 |
Version history: | 16 change(s) |
Referenced in: | [show references] |