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

28
LINES

< > BotCompany Repo | #1032469 // scaledIntegralImage

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

Libraryless. Click here for Pure Java version (5814L/33K).

1  
static IIntegralImage scaledIntegralImage(IIntegralImage img, int w) {
2  
  ret scaledIntegralImage(img, w, iround(w*img.getHeight()/(double) img.getWidth()));
3  
}
4  
5  
static IIntegralImage scaledIntegralImage(IIntegralImage img, int w, int h) {
6  
  ret new IIntegralImage {
7  
    int w1 = img.getWidth(), h1 = img.getHeight();
8  
    double factorX = doubleRatio(w1, w);
9  
    double factorY = doubleRatio(h1, h);
10  
    double areaCorrection = 1/(factorX*factorY);
11  
    
12  
    public int getWidth() { ret w; }
13  
    public int getHeight() { ret h; }
14  
    
15  
    // get value for 1 channel
16  
    // normal range [0; pixelCount*256)
17  
    // TODO: test
18  
    public double getIntegralValue(int x, int y, int channel) {
19  
      double x2 = (x+1)*factorX-1;
20  
      double y2 = (y+1)*factorY-1;
21  
      double val = img.getIntegralValue(x2, y2, channel);
22  
      ifdef scaledIntegralImage_debug
23  
        printVars scaledIntegralImage(+x, +y, +x2, +y2, +val, val2 := val*areaCorrection);
24  
      endifdef
25  
      ret val*areaCorrection;
26  
    }
27  
  };
28  
}

Author comment

Began life as a copy of #1027206

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032469
Snippet name: scaledIntegralImage
Eternal ID of this version: #1032469/5
Text MD5: f5912a1945d44e82ba96cb92965c6c8e
Transpilation MD5: 51a81ba4011c32ceaec3f161fb2aad58
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-08 05:39:41
Source code size: 1026 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 153 / 210
Version history: 4 change(s)
Referenced in: [show references]