Libraryless. Click here for Pure Java version (6186L/37K).
static BWImage scaleDownUsingIntegralImageBW(int w, BWIntegralImage img) { ret scaleDownUsingIntegralImageBW(img, w); } static BWImage scaleDownUsingIntegralImageBW(BWIntegralImage img, int w) { ret scaleDownUsingIntegralImageBW(img, w, iround(w*img.h/(double) img.w)); } static BWImage scaleDownUsingIntegralImageBW(BWIntegralImage img, int w, int h) { int w1 = img.w, h1 = img.h; BWImage out = new(w, h); for y to h: for x to w: { int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); int area = (x2-x1)*(y2-y1); int pixel = bwIntegralImage_sumRect(img, x1, y1, x2, y2)/area; out.setByte(x, y, (byte) pixel); } ret out; } static BWImage scaleDownUsingIntegralImageBW(IBWIntegralImage img, int w, int h default iround(w*img.getHeight()/(double) img.getWidth())) { int w1 = img.getWidth(), h1 = img.getHeight(); BWImage out = new(w, h); for y to h: for x to w: { int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); int area = (x2-x1)*(y2-y1); int pixel = bwIntegralImage_sumRect(img, x1, y1, x2, y2)/area; out.setByte(x, y, (byte) pixel); } ret out; }
Began life as a copy of #1019590
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019597 |
Snippet name: | scaleDownUsingIntegralImageBW (can also scale up) |
Eternal ID of this version: | #1019597/11 |
Text MD5: | ea99cc2c8a471c0be393a37c3c2951b4 |
Transpilation MD5: | fc03f30d392c4cf8b540295c73dea3a4 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-06 18:28:50 |
Source code size: | 1258 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 403 / 543 |
Version history: | 10 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1022980 - virtualScaledIntegralImageBW #1027207 - iBWIntegralImageToBWImage #1033302 - scaledBufferedImageFromBWIntegralImage |