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

24
LINES

< > BotCompany Repo | #1022980 // virtualScaledIntegralImageBW

JavaX fragment (include)

// not scaled
static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img) {
  ret virtualScaledIntegralImageBW(img, img.getWidth(), img.getHeight());
}

static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img, int w) {
  ret virtualScaledIntegralImageBW(img, w, iround(w*img.h/(double) img.w));
}

static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img, int w, int h) {
  ret new IBWImage {
    int w1 = img.w, h1 = img.h;
    public int getWidth() { ret w; }
    public int getHeight() { ret h; }
    
    public float getFloatPixel(int x, int y) {
      int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w);
      int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h);
      int area = (x2-x1)*(y2-y1);
      int pixel = bwIntegralImage_sumRect(img, x1, y1, x2, y2)/area;
      ret pixel/255f;
    }
  };
}

Author comment

Began life as a copy of #1019597

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022980
Snippet name: virtualScaledIntegralImageBW
Eternal ID of this version: #1022980/3
Text MD5: a3a287ce4e2dcf2f02cdb8a0cd900db7
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-17 07:58:04
Source code size: 837 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 262 / 318
Version history: 2 change(s)
Referenced in: [show references]