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

36
LINES

< > BotCompany Repo | #1018876 // Image Segmenter [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (6269L/34K).

!7

cmodule ImageSegmenter > DynImageSurface {
  float contrastThreshold = 0.5f;
  int gridSize = 2;
  transient ReliableSingleThread rst = dm_rst(this, r segmentIt);
  
  visualize {
    JSlider slider = jLiveValueSlider(dm_fieldLiveValue('contrastThreshold));
    main.onChange(slider, rst);
    JSpinner spinner = liveValueSpinner(dm_fieldLiveValue('gridSize), 2, 10);
    main.onChange(spinner, rst);
    ret withCenteredLineBelow(super.visualize(),
      withLabel("Contrast Threshold:", slider),
      withLabel("Grid size:", spinner),
      jbutton("Segment", rst));
  }
  
  start {
    if (!hasImage()) setImage(whiteImage(100, 100));
    dm_vmBus_onMessage('newClipboardContents, voidfunc(O o) {
      if (o cast BufferedImage) thread {
        setImage(o);
        rst.trigger();
      }
    });
  }
  
  void segmentIt enter {
    if (!hasImage()) ret;
    new AutoSegmenter as;
    as.g = gridSize;
    as.contrastThreshold = contrastThreshold;
    overlaySelectionsOnImageSurface(imageSurface, as.go(BWImage(getImage())));
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018876
Snippet name: Image Segmenter [Dyn Module]
Eternal ID of this version: #1018876/14
Text MD5: 540b59b60ecad59aded4e4c3129bcfd0
Transpilation MD5: 7087ddf656e64fefed603e8084ce1535
Author: stefan
Category: javax / image analysis
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-22 01:32:51
Source code size: 1075 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 400 / 1647
Version history: 13 change(s)
Referenced in: [show references]