get("#348") -- rgb functions -- returns value between 0 and 1 -- img must be cropped already function rectangleness(img) local w, h = img.width, img.height local total = 0 for y = 0, h-1 do local sum = 0 for x = 0, w-1 do sum = sum+bright(rgb(img.getInt(x, y))) end sum = sum/w local expected = 0 total = total+math.abs(sum-expected) end return 1-total/h end
Began life as a copy of #496
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: | #497 |
Snippet name: | Rectangle detector (include) |
Eternal ID of this version: | #497/1 |
Text MD5: | e74e064fb56cccadebbbc80a691f92e3 |
Author: | stefan |
Category: | image recognition |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-03-08 20:41:16 |
Source code size: | 425 bytes / 20 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 674 / 156 |
Referenced in: | [show references] |