Transpiled version (29225L) is out of date.
1 | persistable sclass G22PixelSplitMasks<A> is IG22OptimizedMasksHolder<A> { |
2 | replace Mask with IG22Mask<A>. |
3 | |
4 | settable Pt splitPixel; |
5 | settable IG22MasksHolder<A> darkHolder; |
6 | settable IG22MasksHolder<A> brightHolder; |
7 | |
8 | // for search - how much the "correct" branch is preferred |
9 | settable double bias = 0.9; |
10 | |
11 | public L<Mask> masks() { |
12 | ret new ConcatOnDemandList( |
13 | darkHolder.masks(), |
14 | brightHolder.masks()); |
15 | } |
16 | |
17 | public L<IG22MasksHolder<A>> subHolders() { |
18 | ret ll(darkHolder, brightHolder); |
19 | } |
20 | |
21 | public void transformSubHolders(IF1<IG22MasksHolder<A>> f) { |
22 | darkHolder = f.get(darkHolder); |
23 | brightHolder = f.get(brightHolder); |
24 | } |
25 | |
26 | @Override |
27 | public PStackComputable<Void> findSimilarMasks(G22FindSimilarMasksTask<A> task) { |
28 | ret new FindSimilarMasks(task); |
29 | } |
30 | |
31 | record noeq FindSimilarMasks(G22FindSimilarMasksTask task) extends PStackComputableWithStep<Void> is IMakeEmptyClone { |
32 | bool brightBranch; |
33 | |
34 | public selfType makeEmptyClone() { ret new selfType; } |
35 | |
36 | void step(IPStack stack) { |
37 | if (task.ended()) ret with stack.ret(); |
38 | |
39 | if (step == 0) { |
40 | ++step; |
41 | bool bright = isMaskBright(task.queryImage); |
42 | if (task.verbose()) printVars("step 0", +splitPixel, +bright); |
43 | stack.probabilisticOptions(this, ll( |
44 | withProbability(1.0, self -> self.brightBranch = bright), |
45 | withProbability(1-bias, self -> self.brightBranch = !bright))); |
46 | } else { |
47 | if (task.verbose()) printVars("step 1", +splitPixel, +brightBranch); |
48 | IG22MasksHolder<A> branch = brightBranch ? brightHolder : darkHolder; |
49 | stack.tailCall(branch.findSimilarMasks(task)); |
50 | } |
51 | } |
52 | } |
53 | |
54 | // Does the mask belong in darkHolder or brightHolder? |
55 | bool isMaskBright(Image2B maskImage) { |
56 | ret maskImage.getBoolPixel(splitPixel); |
57 | } |
58 | |
59 | public <B> IG22MasksHolder<B> cloneTreeWithLabelTransform(IF1<A, B> f) { |
60 | ret new G22PixelSplitMasks().splitPixel(splitPixel) |
61 | .darkHolder(darkHolder.cloneTreeWithLabelTransform(f)) |
62 | .brightHolder(brightHolder.cloneTreeWithLabelTransform(f)); |
63 | } |
64 | |
65 | !include early #1035854 // Masks holder Include |
66 | } |
Began life as a copy of #1035850
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1035861 |
Snippet name: | G22PixelSplitMasks - masks holder split by brightness of certain pixel |
Eternal ID of this version: | #1035861/30 |
Text MD5: | 1fd5c721af88616edfa656fd254662a1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-09-05 02:47:07 |
Source code size: | 2240 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 190 / 408 |
Version history: | 29 change(s) |
Referenced in: | [show references] |