Skip to content

Instantly share code, notes, and snippets.

@d4vidB
Last active August 29, 2015 14:04
let random_dithering matrix (width, height) style =
(*We convert the image in grey level according to style*)
let new_matrix = grey matrix (width, height) style in
for j = 0 to height - 1 do
for i = 0 to width - 1 do
let threshold = Random.int 256 in
if get_r new_matrix.(i).(j) < threshold then
new_matrix.(i).(j) <- (0, 0 ,0) (*Black*)
else
new_matrix.(i).(j) <- (255, 255, 255); (*White*)
done;
done;
new_matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment