Libraryless. Click here for Pure Java version (15813L/92K).
1 | sclass AbstractFastRegions_ShuffledScan<Img extends WidthAndHeight> is Steppable {
|
2 | AbstractFastRegions<Img> regionMaker; |
3 | WeightlessShuffledIterator iterator; |
4 | |
5 | *(AbstractFastRegions<Img> *regionMaker) {
|
6 | regionMaker.init(); |
7 | iterator = new WeightlessShuffledIterator(regionMaker.size); |
8 | } |
9 | |
10 | public bool step() {
|
11 | ret findNextRegion() > 0; |
12 | } |
13 | |
14 | int findNextRegion() {
|
15 | var regionMatrix = regionMaker.regionMatrix; |
16 | int pixel; |
17 | while ((pixel = iterator.nextIndex()) >= 0) |
18 | if (regionMatrix[pixel] == 0) {
|
19 | regionMaker.runner = pixel; |
20 | ret regionMaker.makeRegion(); |
21 | } |
22 | ret 0; |
23 | } |
24 | |
25 | // null if there are no more regions |
26 | IImageRegion<Img> nextRegion() {
|
27 | int iRegion = findNextRegion(); |
28 | ret iRegion > 0 ? regionMaker.getRegion(iRegion) : null; |
29 | } |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
| Snippet ID: | #1036544 |
| Snippet name: | AbstractFastRegions_ShuffledScan - go through pixels in randomized order to find biggest regions first |
| Eternal ID of this version: | #1036544/9 |
| Text MD5: | 2b17dd1836f2b7197d3ddf98178bf1d1 |
| Transpilation MD5: | 7f3e5512b44d09b82f8613c7db742491 |
| Author: | stefan |
| Category: | javax / imaging |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2023-02-12 15:36:34 |
| Source code size: | 846 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 759 / 944 |
| Version history: | 8 change(s) |
| Referenced in: | [show references] |