function col2hex(num) local hexstr = '0123456789abcdef' local s = '' for i=1, 6 do local mod = math.fmod(num, 16) s = string.sub(hexstr, mod+1, mod+1) .. s num = math.floor(num / 16) end return s end function colortostring(c) if c == 0xFFFFFF then return "white" end return col2hex(c) end w, h = 100, 100 img = {getInt = function (x,y) return x > 2 and x < 98 and y > 2 and y < 98 and -1 or 0 end} ofs = 0 while ofs <= w/2 and ofs <= h/2 do colors = {} for y=ofs, h-ofs-1 do colors[img.getInt(ofs, y)] = 1 colors[img.getInt(w-ofs-1, y)] = 1 end for x=ofs, w-ofs-1 do colors[img.getInt(x, ofs)] = 1 colors[img.getInt(x, h-ofs-1)] = 1 end list, n = {}, 0 for color, _ in pairs(colors) do n=n+1 list[n] = color end if #list > 1 then return ofs == 0 and "no border found" or "border thickness: "..ofs elseif lastcolor == nil then lastcolor = list[1] elseif lastcolor ~= list[1] then return ofs == 0 and "no border found" or "border thickness: "..ofs end ofs = ofs+1 end --return "unicolor "..colortostring(lastcolor) return "unicolor "..lastcolor
Began life as a copy of #302
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 | |
---|---|---|---|---|
344 | #1000604 (pitcher) | 2015-08-18 00:07:22 | ||
343 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { function col2hex(num) local hexstr = '0123456789abcdef' local s = '' for i=1, 6 do local mod = math.fmod(num, 16) s = string.sub(hexstr, mod+1, mod+1) .. s num = math.floor(num / 16) end return s end function colortostring(c) if c == 0xFFFFFF then return "white" end return col2hex(c) end w, h = 100, 100 img = {getInt = function (x,y) return x > 2 and x < 98 and y > 2 and y < 98 and -1 or 0 end} ofs = 0 while ofs <= w/2 and ofs <= h/2 do colors = {} for y=ofs, h-ofs-1 do colors[img.getInt(ofs, y)] = 1 colors[img.getInt(w-ofs-1, y)] = 1 end for x=ofs, w-ofs-1 do colors[img.getInt(x, ofs)] = 1 colors[img.getInt(x, h-ofs-1)] = 1 end list, n = {}, 0 for color, _ in pairs(colors) do n=n+1 list[n] = color end if #list > 1 then return ofs == 0 and "no border found" or "border thickness: "..ofs elseif lastcolor == nil then lastcolor = list[1] elseif lastcolor ~= list[1] then return ofs == 0 and "no border found" or "border thickness: "..ofs end ofs = ofs+1 end --return "unicolor "..colortostring(lastcolor) return "unicolor "..lastcolor }} | 2015-08-18 03:11:31 | delete |
Recognizer | Recognition Result | Visualize | Recalc |
---|---|---|---|
#308 | 1211 | [visualize] |
Snippet ID: | #304 |
Snippet name: | Find border thickness bug test |
Eternal ID of this version: | #304/1 |
Text MD5: | 10bc997feb46fdee8e32ccb43c84f74f |
Author: | stefan |
Category: | image recognition |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2014-12-25 20:39:07 |
Source code size: | 1211 bytes / 56 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1281 / 304 |
Referenced in: | [show references] |