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.

scope test_G22RegionThinner

sS test_G22RegionThinner(int repetitions, S imgString) {
  ret applyNTimes test_G22RegionThinner(repetitions, imgString);
}

sS test_G22RegionThinner(S imgString, bool allSteps default false) {
  var img = bwImageFromString(imgString);
  //img = bwWhiteBorder(1, 1, img);
  
  var image = toBufferedImage(img);
  
  var itr = Gazelle22_ImageToRegions(
    new FunctionTimings, image, new SnPSettings(image, 2));
  itr.withDiagonals(true);
  var region = g22_darkestRegion(itr!);
  
  G22RegionThinner_v2 thinner = new(region);
  if (allSteps) stepAll(thinner); else step(thinner);
  ret bwImageToString(regionToBWImage_fullImageSize(thinner!));
}

svoid #test(S in, S out, bool allSteps default false) {
  testFunctionValue(s -> "\n" + test_G22RegionThinner(s, allSteps), in, "\n" + mlsUnindent(out));
}

svoid test_G22RegionThinner() {
  test(
    [[
      #####
      #####
      #####
    ]],
    [[
      _____
      _###_
      _____
    ]]);
    
  test(
    [[
      #####
      #####
    ]],
    [[
      #####
      #####
    ]]);
    
  test(
    [[
      ______
      _##___
      _###__
      __##__
      ____#_
      ______
    ]],
    [[
      ______
      ______
      __##__
      __##__
      ____#_
      ______
    ]]);
    
  test(
    [[
      ######_
      #####__
      #####__
      ######_
      ######_
      #######
      ######_
      #######
      ########_
      #######__
    ]],
    [[
      _______
      _###___
      _###___
      _####__
      _####__
      _#####_
      _####__
      _#####_
      _#####_
      _______
    ]]);
    
  theKProblem();
  theEProblem();
}

svoid #theKProblem {
  test(
    [[
      #____###
      #___###_
      #__###__
      #_###___
      ####____
    ]],
    [[
      #_______
      #____#__
      #____#__
      #___#___
      ####____
    ]], true);
    
  test(
    [[
      ####____
      #_###___
      #__###__
      #___###_
      #____###
    ]],
    [[
      ##______
      #_#_____
      #__#____
      #___##__
      #_______
    ]], true);
}

svoid #theEProblem(bool allSteps default true) {
  test(
    [[
      #______
      ##_____
      ###____
      #######
      ###____
      ##_____
      #______
    ]],
    [[
      _______
      _#_____
      __#####
      _#_____
      _______
      _______
    ]], allSteps);
}

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: 96 / 281
Version history: 28 change(s)
Referenced in: [show references]