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

36
LINES

< > BotCompany Repo | #1034885 // scaledPixelsFromIntegralImage - scale (I)IntegralImage down to a pixel array

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

Libraryless. Click here for Pure Java version (11532L/67K).

1  
meta-for IntegralImage also as IIntegralImage {
2  
3  
  static int[] scaledPixelsFromIntegralImage(int w, IntegralImage img) {
4  
    ret scaledPixelsFromIntegralImage(img, w);
5  
  }
6  
  
7  
  static int[] scaledPixelsFromIntegralImage(IntegralImage img, int w,
8  
    int h default heightForWidth(img, w)) {
9  
    int w1 = img.getWidth(), h1 = img.getHeight();
10  
    double stepX = doubleRatio(w1, w), stepY = doubleRatio(h1, h);
11  
    int[] pixels = new[w*h];
12  
    int i = 0;
13  
    double srcY = 0;
14  
    double area = stepX*stepY;
15  
    
16  
    printVars ifdef scaledPixelsFromIntegralImage_debug("scaledPixelsFromIntegralImage", +w, +h, +w1, +h1, +stepX, +stepY, +area);
17  
    
18  
    for y to h: {
19  
      double srcX = 0, nextSrcY = srcY+stepY;
20  
      
21  
      for x to w: {
22  
        double nextSrcX = srcX+stepX;
23  
        dbl r = doubleRatio(img.rectSum(srcX, srcY, nextSrcX, nextSrcY, 0), area);
24  
        dbl g = doubleRatio(img.rectSum(srcX, srcY, nextSrcX, nextSrcY, 1), area);
25  
        dbl b = doubleRatio(img.rectSum(srcX, srcY, nextSrcX, nextSrcY, 2), area);
26  
        printVars ifdef scaledPixelsFromIntegralImage_debug("scaledPixelsFromIntegralImage", +r, +g, +b);
27  
        pixels[i++] = rgbIntFromDoubles_fullAlpha(r, g, b);
28  
        srcX = nextSrcX;
29  
      }
30  
      srcY = nextSrcY;
31  
    }
32  
    
33  
    ret pixels;
34  
  }
35  
36  
}

Author comment

Began life as a copy of #1033676

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1034885
Snippet name: scaledPixelsFromIntegralImage - scale (I)IntegralImage down to a pixel array
Eternal ID of this version: #1034885/9
Text MD5: 412af4d521461a03755f69efb75b94c2
Transpilation MD5: 342a497d12cad6a8aadce1454c0d8950
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-21 01:49:18
Source code size: 1314 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 84 / 160
Version history: 8 change(s)
Referenced in: [show references]