get("#372") -- getContrast _, _, min, max = getContrast(img) -- copy image and invert w, h = img.width, img.height pixels = {} for y = 0, h-1 do for x = 0, w-1 do b = bright(rgb(img.getInt(x, y))) n = math.max(0, math.min(255, math.floor((b-min)/(max-min)*255+0.5))) pixels[y*w+x+1] = n*0x010101 end end
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: | #373 |
Snippet name: | Maximize Contrast (also convert to black/white) |
Eternal ID of this version: | #373/1 |
Text MD5: | ddddde999a932b220c6c3c25fe656026 |
Author: | stefan |
Category: | image transformers |
Type: | Lua code - Image transformer |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-02-03 21:27:24 |
Source code size: | 338 bytes / 15 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 756 / 191 |
Referenced in: | [show references] |