Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

151
LINES

< > BotCompany Repo | #1034981 // test_G22RegionThinner

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (18721L) is out of date.

1  
scope test_G22RegionThinner
2  
3  
sS test_G22RegionThinner(int repetitions, S imgString) {
4  
  ret applyNTimes test_G22RegionThinner(repetitions, imgString);
5  
}
6  
7  
sS test_G22RegionThinner(S imgString, bool allSteps default false) {
8  
  var img = bwImageFromString(imgString);
9  
  //img = bwWhiteBorder(1, 1, img);
10  
  
11  
  var image = toBufferedImage(img);
12  
  
13  
  var itr = Gazelle22_ImageToRegions(
14  
    new FunctionTimings, image, new SnPSettings(image, 2));
15  
  itr.withDiagonals(true);
16  
  var region = g22_darkestRegion(itr!);
17  
  
18  
  G22RegionThinner_v2 thinner = new(region);
19  
  if (allSteps) stepAll(thinner); else step(thinner);
20  
  ret bwImageToString(regionToBWImage_fullImageSize(thinner!));
21  
}
22  
23  
svoid #test(S in, S out, bool allSteps default false) {
24  
  testFunctionValue(s -> "\n" + test_G22RegionThinner(s, allSteps), in, "\n" + mlsUnindent(out));
25  
}
26  
27  
svoid test_G22RegionThinner() {
28  
  test(
29  
    [[
30  
      #####
31  
      #####
32  
      #####
33  
    ]],
34  
    [[
35  
      _____
36  
      _###_
37  
      _____
38  
    ]]);
39  
    
40  
  test(
41  
    [[
42  
      #####
43  
      #####
44  
    ]],
45  
    [[
46  
      #####
47  
      #####
48  
    ]]);
49  
    
50  
  test(
51  
    [[
52  
      ______
53  
      _##___
54  
      _###__
55  
      __##__
56  
      ____#_
57  
      ______
58  
    ]],
59  
    [[
60  
      ______
61  
      ______
62  
      __##__
63  
      __##__
64  
      ____#_
65  
      ______
66  
    ]]);
67  
    
68  
  test(
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  
  theKProblem();
95  
  theEProblem();
96  
}
97  
98  
svoid #theKProblem {
99  
  test(
100  
    [[
101  
      #____###
102  
      #___###_
103  
      #__###__
104  
      #_###___
105  
      ####____
106  
    ]],
107  
    [[
108  
      #_______
109  
      #____#__
110  
      #____#__
111  
      #___#___
112  
      ####____
113  
    ]], true);
114  
    
115  
  test(
116  
    [[
117  
      ####____
118  
      #_###___
119  
      #__###__
120  
      #___###_
121  
      #____###
122  
    ]],
123  
    [[
124  
      ##______
125  
      #_#_____
126  
      #__#____
127  
      #___##__
128  
      #_______
129  
    ]], true);
130  
}
131  
132  
svoid #theEProblem(bool allSteps default true) {
133  
  test(
134  
    [[
135  
      #______
136  
      ##_____
137  
      ###____
138  
      #######
139  
      ###____
140  
      ##_____
141  
      #______
142  
    ]],
143  
    [[
144  
      _______
145  
      _#_____
146  
      __#####
147  
      _#_____
148  
      _______
149  
      _______
150  
    ]], allSteps);
151  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034981
Snippet name: test_G22RegionThinner
Eternal ID of this version: #1034981/29
Text MD5: 83404a69cb17f91866b2fb98e8f56913
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-30 04:53:33
Source code size: 2489 bytes / 151 lines
Pitched / IR pitched: No / No
Views / Downloads: 172 / 380
Version history: 28 change(s)
Referenced in: [show references]