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

24
LINES

< > BotCompany Repo | #1022980 // virtualScaledIntegralImageBW

JavaX fragment (include)

1  
// not scaled
2  
static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img) {
3  
  ret virtualScaledIntegralImageBW(img, img.getWidth(), img.getHeight());
4  
}
5  
6  
static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img, int w) {
7  
  ret virtualScaledIntegralImageBW(img, w, iround(w*img.h/(double) img.w));
8  
}
9  
10  
static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img, int w, int h) {
11  
  ret new IBWImage {
12  
    int w1 = img.w, h1 = img.h;
13  
    public int getWidth() { ret w; }
14  
    public int getHeight() { ret h; }
15  
    
16  
    public float getFloatPixel(int x, int y) {
17  
      int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w);
18  
      int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h);
19  
      int area = (x2-x1)*(y2-y1);
20  
      int pixel = bwIntegralImage_sumRect(img, x1, y1, x2, y2)/area;
21  
      ret pixel/255f;
22  
    }
23  
  };
24  
}

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: 263 / 319
Version history: 2 change(s)
Referenced in: [show references]