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

26
LINES

< > BotCompany Repo | #1034422 // G22ColorWalker - G22Walker for IRGBImage

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

Transpiled version (6082L) is out of date.

sclass G22ColorWalker > G22Walker<IRGBImage> {
  // the ideal image it is looking for (set/get)
  int[] rememberedImage; // size visionW*visionH
  
  // only works when we already have a rememberedImage
  double scorePosition(Pt pos, IRGBImage image) {
    int vx = pos.x-visionW, vy = pos.y-visionH, i = 0;
    int diff = 0;
    for y to visionH:
      for x to visionW:
        diff += colorDistance(rememberedImage[i++], image.getIntPixel(vx+x, vy+y));
    ret -diff;
  }
  
  bool hasRememberedImage() { ret rememberedImage != null; }
  
  void rememberImage(IRGBImage image) {
    if (rememberedImage == null)
      rememberedImage = new int[visionW*visionH];
      
    int vx = visionX1(), vy = visionY1(), i = 0;
    for y to visionH:
      for x to visionW:
        rememberedImage[i++] = image.getIntPixel(vx+x, vy+y);
  }
}

Author comment

Began life as a copy of #1034119

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034422
Snippet name: G22ColorWalker - G22Walker for IRGBImage
Eternal ID of this version: #1034422/5
Text MD5: 1194fac1b46bdca2e2960d5e234ecb00
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-14 15:31:41
Source code size: 859 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 143 / 222
Version history: 4 change(s)
Referenced in: [show references]