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("#388") -- rect functions
get("#410") -- shrinkRectangle
get("#380") -- hashImage
get("#460") -- floodfill
w, h = img.width, img.height
g = 3 -- grid size
gw, gh = math.floor(w/g), math.floor(h/g) -- width & height of grid
grid = {}
for gy = 0, h-g, g do
for gx = 0, w-g, g do
local min, max = 1, 0
for y = gy, gy+g-1 do
for x = gx, gx+g-1 do
local b = bright(rgb(img.getInt(x, y)))
min, max = math.min(min, b), math.max(max, b)
if min < 0.5 and max > 0.5 then
grid[(gy/g)*gw+(gx/g)+1] = true
goto next
end
end
end
::next::
end
end
result = {}
for y = 0, gh-1 do
for x = 0, gw-1 do
r = nil
fill {{x, y, 1}}
if r then
--table.insert(result, (x*g).."/"..(y*g).."-"..c)
r = scaleRectangle(r, g)
r = shrinkRectangle(r, img)
local cropped = {width=r.width, height=r.height,
getInt = function(x, y) return img.getInt(x+r.x, y+r.y) end}
local hash = hashImage(cropped)
table.insert(result, recttostring(r).." -> "..hash)
end
end
end
return "Floodfill: "..table.concat(result, "|")