Libraryless. Click here for Pure Java version (13149L/76K).
1 | meta-for BWIntegralImage also as IBWIntegralImage { |
2 | |
3 | static byte[] scaledGrayBytesFromBWIntegralImage(int w, BWIntegralImage img) { |
4 | ret scaledGrayBytesFromBWIntegralImage(img, w); |
5 | } |
6 | |
7 | static byte[] scaledGrayBytesFromBWIntegralImage(BWIntegralImage img, int w, int h default heightForWidth(img, w)) { |
8 | int w1 = img.getWidth(), h1 = img.getHeight(); |
9 | double stepX = doubleRatio(w1, w), stepY = doubleRatio(h1, h); |
10 | byte[] pixels = new[w*h]; |
11 | int i = 0; |
12 | double srcY = 0; |
13 | |
14 | if (stepX == 1 && stepY == 1) { |
15 | // No scaling |
16 | |
17 | for y to h: |
18 | for x to w: { |
19 | int pixel = img.getPixelBrightness(x, y); |
20 | pixels[i++] = clampToUByte(pixel); |
21 | } |
22 | } else { |
23 | // With arbitrary scaling |
24 | |
25 | for y to h: { |
26 | double srcX = 0, nextSrcY = srcY+stepY; |
27 | |
28 | for x to w: { |
29 | double nextSrcX = srcX+stepX; |
30 | int pixel = iround(img.getPixelAverage(srcX, srcY, nextSrcX, nextSrcY)); |
31 | pixels[i++] = clampToUByte(pixel); |
32 | srcX = nextSrcX; |
33 | } |
34 | srcY = nextSrcY; |
35 | } |
36 | } |
37 | |
38 | ret pixels; |
39 | } |
40 | |
41 | } |
Began life as a copy of #1033440
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033676 |
Snippet name: | scaledGrayBytesFromBWIntegralImage |
Eternal ID of this version: | #1033676/5 |
Text MD5: | f38e44871bd093087bb2a56c7091d3c2 |
Transpilation MD5: | 0620d3650c5f1926b87cb43f00baddc3 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-26 03:54:02 |
Source code size: | 1173 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 134 / 213 |
Version history: | 4 change(s) |
Referenced in: | [show references] |