get("#348") -- rgb functions get("#346") -- getcrop get("#337") -- map(list, f) get("#388") -- rectangle functions brightnessThreshold = 0.9 function horizontalsplit(img) local function isEmpty(x) for y=0, img.height-1 do if bright(rgb(img.getInt(x, y))) <= brightnessThreshold then return false end end return true end local lastEmpty, start = true, nil local segments = {} for x=0, img.width-1 do empty = isEmpty(x) if empty and not lastEmpty then table.insert(segments, {start, x}) elseif not empty and lastEmpty then start = x end lastEmpty = empty end if not lastEmpty then table.insert(segments, {start, img.width}) end if #segments <= 1 then -- don't bother with only 1 segment return {} end local result = {} for _, seg in ipairs(segments) do local sx1, sx2 = unpack(seg) local cropped = { width = sx2-sx1, height = img.height, getInt = function(x, y) return img.getInt(x+sx1, y) end } local x1, y1, x2, y2 = getcrop(cropped) table.insert(result, newRectangle(x1+sx1, y1, x2-x1, y2-y1)) end return result end
Began life as a copy of #345
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
Image | Result | Result calculated |
---|---|---|
#1000146 | nil | 2016-08-03 18:03:22 Lua instructions: 2k [raw result] [visualize] |
#1000141 | nil | 2016-08-01 02:54:45 Lua instructions: 2k [raw result] [visualize] |
#1000176 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000168 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000147 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000128 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#84 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-08-01 02:54:44 [raw result] [visualize] |
#1000180 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#87 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-08-01 02:54:44 [raw result] [visualize] |
#1000152 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000140 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000179 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000175 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000163 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000177 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000081 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#92 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-08-01 02:54:44 [raw result] [visualize] |
#1000151 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000160 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000158 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000138 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#93 | java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... | 2016-08-01 02:54:44 [raw result] [visualize] |
#1000150 | nil | 2016-08-01 02:54:44 Lua instructions: 2k [raw result] [visualize] |
#1000181 | nil | 2016-08-01 02:54:43 Lua instructions: 2k [raw result] [visualize] |
#1000182 | nil | 2016-08-01 02:54:43 Lua instructions: 2k [raw result] [visualize] |
Snippet ID: | #478 |
Snippet name: | Horizontal split with crop (include) |
Eternal ID of this version: | #478/1 |
Text MD5: | cbc8adaf3de51544d5ca7de9cbeda693 |
Author: | stefan |
Category: | |
Type: | Lua code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-02-25 19:25:17 |
Source code size: | 1243 bytes / 54 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 2011 / 191 |
Referenced in: | [show references] |