get("#372") -- getContrast brightnessThreshold = 0.55 -- convert pixel by pixel 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))) pixels[y*w+x+1] = b >= brightnessThreshold and -1 or 0 end 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: | #505 |
Snippet name: | Convert image to 1 bit (threshold 55%) |
Eternal ID of this version: | #505/1 |
Text MD5: | 02b6b2a3d1c9d26df18deb60f438a826 |
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:14:15 |
Source code size: | 283 bytes / 14 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 707 / 178 |
Referenced in: | #1000232 - Coffee b/w 55% #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |