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

30
LINES

< > BotCompany Repo | #1036544 // AbstractFastRegions_ShuffledScan - go through pixels in randomized order to find biggest regions first

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

Libraryless. Click here for Pure Java version (15813L/92K).

sclass AbstractFastRegions_ShuffledScan<Img extends WidthAndHeight> is Steppable {
  AbstractFastRegions<Img> regionMaker;
  WeightlessShuffledIterator iterator;
  
  *(AbstractFastRegions<Img> *regionMaker) {
    regionMaker.init();
    iterator = new WeightlessShuffledIterator(regionMaker.size);
  }
  
  public bool step() {
    ret findNextRegion() > 0;
  }
  
  int findNextRegion() {
    var regionMatrix = regionMaker.regionMatrix;
    int pixel;
    while ((pixel = iterator.nextIndex()) >= 0)
      if (regionMatrix[pixel] == 0) {
        regionMaker.runner = pixel;
        ret regionMaker.makeRegion();
      }
    ret 0;
  }
  
  // null if there are no more regions
  IImageRegion<Img> nextRegion() {
    int iRegion = findNextRegion();
    ret iRegion > 0 ? regionMaker.getRegion(iRegion) : null;
  }
}

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: 159 / 257
Version history: 8 change(s)
Referenced in: [show references]