brightnessThreshold = 0.9 maxSignatureLen = 10 function rgb(i) local r = bit32.band(bit32.rshift(i, 16), 255) local g = bit32.band(bit32.rshift(i, 8), 255) local b = bit32.band(i, 255) return r, g, b end function bright(r, g, b) return (r+g+b)/(255*3) end -- from Java class "SegmentCounter" function countSegments(y, flip) local lastPix = 1 local segments = 0 for x = 0, (flip and h or w)-1 do local pix = bright(rgb(flip and img.getInt(y, x) or img.getInt(x, y))) if pix >= brightnessThreshold and lastPix < brightnessThreshold then segments = segments+1 end lastPix = pix end if lastPix < brightnessThreshold then segments = segments+1 end return segments end function getSegmentSignature(flip) local s = "" local lastN = 0 for y = 0, (flip and w or h)-1 do local n = math.min(countSegments(y, flip), 9) if n ~= lastN then if #s >= maxSignatureLen then return nil end s = s..n end lastN = n end if lastN == 0 and #s > 0 then s = s:sub(1, #s-1) end return s end
Began life as a copy of #334
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 | |
---|---|---|---|---|
559 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { brightnessThreshold = 0.9 maxSignatureLen = 10 function rgb(i) local r = bit32.band(bit32.rshift(i, 16), 255) local g = bit32.band(bit32.rshift(i, 8), 255) local b = bit32.band(i, 255) return r, g, b end function bright(r, g, b) return (r+g+b)/(255*3) end -- from Java class "SegmentCounter" function countSegments(y, flip) local lastPix = 1 local segments = 0 for x = 0, (flip and h or w)-1 do local pix = bright(rgb(flip and img.getInt(y, x) or img.getInt(x, y))) if pix >= brightnessThreshold and lastPix < brightnessThreshold then segments = segments+1 end lastPix = pix end if lastPix < brightnessThreshold then segments = segments+1 end return segments end function getSegmentSignature(flip) local s = "" local lastN = 0 for y = 0, (flip and w or h)-1 do local n = math.min(countSegments(y, flip), 9) if n ~= lastN then if #s >= maxSignatureLen then return nil end s = s..n end lastN = n end if lastN == 0 and #s > 0 then s = s:sub(1, #s-1) end return s end }} | 2015-08-18 20:25:42 | delete |
557 | #1000604 (pitcher) | 2015-08-18 00:07:22 |