function getLeftmostPoint(y)
local x1 = 0
while x1 < img.width and img.getInt(x1, y) >= 0xF00000 do
x1 = x1+1
end
return x1
end
function getRightmostPoint(y)
local x2 = img.width
while x2 > 0 and img.getInt(x2-1, y) >= 0xF00000 do
x2 = x2-1
end
return x2
end
function getWidth(y)
local x2 = getRightmostPoint(y)
local x1 = getLeftmostPoint(y)
return math.max(0, x2-x1)
end
function getAverageWidth(y1, y2)
local sum = 0
for y = y1, y2-1 do
sum = sum+getWidth(y)
end
return sum/(y2-y1)
end
function upperWidthToLowerWidth()
local upper = getAverageWidth(0, math.floor(img.height/3))
local lower = getAverageWidth(math.floor(img.height*2/3), img.height)
return upper/lower
endtest 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: | #343 |
| Snippet name: | RecogUtil |
| Eternal ID of this version: | #343/1 |
| Text MD5: | ae07172ab7235e0f4b52cdf4d1ef496a |
| Author: | stefan |
| Category: | image recognition |
| Type: | Lua code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-01-26 01:45:37 |
| Source code size: | 760 bytes / 35 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 884 / 216 |
| Referenced in: | #350 - RecogUtil 2 #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |