function tablelength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end function getcrop(img) local w, h, g = img.width, img.height, img.getInt local x1, y1, x2, y2 = 0, 0, w, h -- left side local colors = {} while x1 < x2 do for y=y1, y2-1 do colors[g(x1, y)] = 1 end if tablelength(colors) > 1 then break end x1=x1+1 end -- top side colors = {} while y1 < y2 do for x=x1, x2-1 do colors[g(x, y1)] = 1 end if tablelength(colors) > 1 then break end y1=y1+1 end -- right side colors = {} while x2 > x1 do for y=y1, y2-1 do colors[g(x2-1, y)] = 1 end if tablelength(colors) > 1 then break end x2=x2-1 end -- bottom side colors = {} while y2 > y1 do for x=x1, x2-1 do colors[g(x, y2-1)] = 1 end if tablelength(colors) > 1 then break end y2=y2-1 end if x2 <= x1 or y2 <= y1 then -- weird result? return full image x1, y1, x2, y2 = 0, 0, w, h end return x1, y1, x2, y2 end
Began life as a copy of #324
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 |
---|---|---|---|
208 | #1000604 (pitcher) | 2015-08-18 00:51:07 | |
190 | #1000610 (pitcher) | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { function tablelength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end function getcrop(img) local w, h, g = img.width, img.height, img.getInt local x1, y1, x2, y2 = 0, 0, w, h -- left side local colors = {} while x1 < x2 do for y=y1, y2-1 do colors[g(x1, y)] = 1 end if tablelength(colors) > 1 then break end x1=x1+1 end -- top side colors = {} while y1 < y2 do for x=x1, x2-1 do colors[g(x, y1)] = 1 end if tablelength(colors) > 1 then break end y1=y1+1 end -- right side colors = {} while x2 > x1 do for y=y1, y2-1 do colors[g(x2-1, y)] = 1 end if tablelength(colors) > 1 then break end x2=x2-1 end -- bottom side colors = {} while y2 > y1 do for x=x1, x2-1 do colors[g(x, y2-1)] = 1 end if tablelength(colors) > 1 then break end y2=y2-1 end if x2 <= x1 or y2 <= y1 then -- weird result? return full image x1, y1, x2, y2 = 0, 0, w, h end return x1, y1, x2, y2 end }} | 2015-08-18 00:50:25 |
Image | Result | Result calculated |
---|---|---|
#1000003 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#201 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#183 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#182 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#178 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#145 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#141 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#115 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#113 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#112 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#100 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#98 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#93 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#92 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#91 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#90 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#87 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#85 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#84 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#49 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#48 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:18 [raw result] [visualize] |
#1000053 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:13 [raw result] [visualize] |
#309 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-07-31 19:44:13 [raw result] [visualize] |
Snippet ID: | #346 |
Snippet name: | Embeddable border finder (getcrop) |
Eternal ID of this version: | #346/1 |
Text MD5: | be12f03a9dba5ea4b45c2fe06a806153 |
Author: | stefan |
Category: | image recognition |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-01-26 00:23:52 |
Source code size: | 1135 bytes / 61 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 1406 / 289 |
Referenced in: | [show references] |