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

18
LINES

< > BotCompany Repo | #1036077 // binaryImageOutline

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

Transpiled version (11127L) is out of date.

static Image2B binaryImageOutline(IImage2B image) {
  int w = image.w(), h = image.h();
  ret image == null ?: binaryImageFromFunction(w+2, h+2,
    (x, y) ->
      !(
        // white if pixel was black before
        getBoolPixelDefaultTrue(image, x, y) ? false
        // otherwise, black if surrounded by at least one black pixel
      : (
        getBoolPixelDefaultTrue(image, x-1, y-1)
      || getBoolPixelDefaultTrue(image, x, y-1)
      || getBoolPixelDefaultTrue(image, x+1, y-1)
      || getBoolPixelDefaultTrue(image, x-1, y)
      || getBoolPixelDefaultTrue(image, x+1, y)
      || getBoolPixelDefaultTrue(image, x-1, y+1)
      || getBoolPixelDefaultTrue(image, x, y+1)
      || getBoolPixelDefaultTrue(image, x+1, y+1))));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036077
Snippet name: binaryImageOutline
Eternal ID of this version: #1036077/3
Text MD5: 0262d3e8c328010cf4a20ec20f8c3c43
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-05 03:57:49
Source code size: 757 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 63 / 101
Version history: 2 change(s)
Referenced in: [show references]