1 | get("#372") -- getContrast
|
2 | |
3 | brightnessThreshold = 0.6 |
4 | |
5 | -- convert pixel by pixel |
6 | |
7 | w, h = img.width, img.height |
8 | pixels = {}
|
9 | for y = 0, h-1 do |
10 | for x = 0, w-1 do |
11 | b = bright(rgb(img.getInt(x, y))) |
12 | pixels[y*w+x+1] = b >= brightnessThreshold and -1 or 0 |
13 | end |
14 | end |
Began life as a copy of #503
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: | #504 |
| Snippet name: | Convert image to 1 bit (threshold 60%) |
| Eternal ID of this version: | #504/1 |
| Text MD5: | e6a121337fdd4ac08a49cf8786ee6bb7 |
| 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:13:18 |
| Source code size: | 282 bytes / 14 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 953 / 190 |
| Referenced in: | [show references] |