get("#348") -- rgb functions -- returns value between 0 and 1 -- img must be cropped already function triangleness(img) local w, h = img.width, img.height local stepx = w < 40 and 1 or 4 local stepy = h < 40 and 1 or 4 local total = 0 for y = 0, h-1, stepy do local sum = 0 for x = 0, w-1, stepx do sum = sum+bright(rgb(img.getInt(x, y))) end sum = sum/math.floor(w/stepx) local expected = 1-(y+1)/h total = total+math.abs(sum-expected) end return 1-total/math.floor(h/stepy) end