1 | get("#356") -- num2hex |
2 | get("#348") -- rgb functions |
3 | |
4 | function roughHashImage(img) |
5 | local hash = 0 |
6 | local w, h = img.width, img.height |
7 | |
8 | for y = 0, h-1 do |
9 | for x = 0, w-1 do |
10 | local pix = img.getInt(x, y) |
11 | local b = math.floor(bright(rgb(pix))*25+0.5) |
12 | local p = b |
13 | local scale = bit32.band(y*w+x, 0xFFFF)+1 |
14 | local arg = ((p+1)*scale*7) % 1234567 |
15 | hash = bit32.bxor(hash, arg) |
16 | --[[if x < 10 then |
17 | print("scale", scale, "pix", pix, "p", p, "arg", arg, "hash", hash) |
18 | end]] |
19 | end |
20 | --print("y", y, "hash", hash) |
21 | end |
22 | |
23 | return num2hex(hash, 8) |
24 | end |
Began life as a copy of #380
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
ID | Author/Program | Comment | Date |
---|---|---|---|
965 | #1000604 (pitcher) | 2015-08-20 15:28:24 | |
964 | #1000610 (pitcher) | 2015-08-18 00:07:07 |
Snippet ID: | #415 |
Snippet name: | Rough-Hash Function |
Eternal ID of this version: | #415/1 |
Text MD5: | 7e158c2267faa430c6f33a04342096ef |
Author: | stefan |
Category: | hash functions |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-02-06 13:46:44 |
Source code size: | 629 bytes / 24 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 979 / 164 |
Referenced in: | [show references] |