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

36
LINES

< > BotCompany Repo | #1033566 // ScaledIBWIntegralImage [OK]

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

Libraryless. Click here for Pure Java version (11630L/68K).

1  
sclass ScaledIBWIntegralImage > Meta implements IBWIntegralImage {
2  
  IBWIntegralImage img;
3  
  int w, h;
4  
  double factorX, factorY, areaCorrection;
5  
  
6  
  static ScaledIBWIntegralImage forHeight(int h, IBWIntegralImage img) {
7  
    ret new ScaledIBWIntegralImage(widthForHeight(img.getWidth(), img.getHeight(), h), img);
8  
  }
9  
10  
  *(int w, IBWIntegralImage img) {
11  
    this(w, heightForWidth(img.getWidth(), img.getHeight(), w), img);
12  
  }
13  
14  
  *(int *w, int *h, IBWIntegralImage *img) {
15  
    h = heightForWidth(img.getWidth(), img.getHeight(), w); 
16  
    int w1 = img.getWidth(), h1 = img.getHeight();
17  
    factorX = doubleRatio(w1, w);
18  
    factorY = doubleRatio(h1, h);
19  
    areaCorrection = 1/(factorX*factorY);
20  
  }
21  
    
22  
  public int getWidth() { ret w; }
23  
  public int getHeight() { ret h; }
24  
    
25  
  // get value for 1 channel
26  
  // normal range [0; pixelCount*256)
27  
  // TODO: test
28  
  public dbl getIIValue(double x, double y) {
29  
    dbl x2 = (x+1)*factorX-1, y2 = (y+1)*factorY-1;
30  
    dbl val = img.getIIValue(x2, y2)*areaCorrection;
31  
    ifdef ScaledIBWIntegralImage_debug
32  
    print("Scaled." + formatFunctionCall getIIValue(x, y, x2, y2) + "=" + val);
33  
    endifdef
34  
    ret val;
35  
  }
36  
}

Author comment

Began life as a copy of #1027206

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033566
Snippet name: ScaledIBWIntegralImage [OK]
Eternal ID of this version: #1033566/10
Text MD5: 9ddb856f3f16d10550bc4b2e99e98174
Transpilation MD5: 4e56c53b6bbca1d82b6244aa044d3344
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-05 02:02:14
Source code size: 1201 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 218 / 316
Version history: 9 change(s)
Referenced in: [show references]