-- Color Threshold
-- origine : http://www.mark0.net/plugins-doglua-samp-e.html

level = 0.5

function threshold(val)
  if val < level then
    return 0
  else
    return 1
  end
end

for y = 0, height - 1 do
  for x = 0, width - 1 do
    r, g, b = get_rgb(x, y)
    r = threshold(r)
    g = threshold(g)
    b = threshold(b)
    set_rgb(x, y, r, g, b)
  end
  progress(y / height)
end
