get("#507") -- averageBrightness ow, oh = img.width, img.height g = math.min(ow, oh)/4 -- grid size -- copy image and invert pixels = {} w, h = math.floor(ow/g), math.floor(oh/g) for y = 0, h-1 do for x = 0, w-1 do x1 = math.floor(x*g+0.5) y1 = math.floor(y*g+0.5) x2 = math.floor((x+1)*g+0.5) y2 = math.floor((y+1)*g+0.5) b = averageBrightness(img, x1, y1, x2, y2) n = math.max(0, math.min(255, math.floor(b*255+0.5))) pixels[y*w+x+1] = n*0x010101 end end
Began life as a copy of #373
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #506 |
Snippet name: | Shrink to 4*x (or x*4) with x >= 4 |
Eternal ID of this version: | #506/1 |
Text MD5: | d6e0f21b3e14bc56aa4bf3c95a9fb7af |
Author: | stefan |
Category: | image transformers |
Type: | Lua code - Image transformer |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-03-09 18:31:05 |
Source code size: | 518 bytes / 22 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 738 / 162 |
Referenced in: | [show references] |