Warning: session_start(): open(/var/lib/php/sessions/sess_3gn886gnnijdl5lg27c0f39m5m, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
get("#348") -- rgb functions
get("#346") -- getcrop
get("#337") -- map(list, f)
w, h = img.width, img.height
brightnessThreshold = 0.9
function isEmpty(x)
for y=0, h-1 do
if bright(rgb(img.getInt(x, y))) <= brightnessThreshold then
return false
end
end
return true
end
lastEmpty = true
segments = {}
for x=0, w-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, w})
end
if #segments <= 1 then -- don't bother with only 1 segment
return
end
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, (x1+sx1)..", "..y1..", "..(x2+sx1)..", "..y2)
end
return "Parts: "..table.concat(result, "|")