You are reading a single comment by @moocher and its replies.
Click here to read the full conversation.
-
This is how you might get the colour value for each block in Python, using
pillow
, the standard image processing library. You could do the posterisation as well.Code formatting doesn't seem to quite work,
//
is integer division, not a commentfrom PIL import Image BLOCK_SIZE = 40 img = Image.open('image.png') img_x, img_y = img.size for x_block in range(img_x // BLOCK_SIZE): for y_block in range(img_y // BLOCK_SIZE): colour = img.getpixel((x_block * BLOCK_SIZE, y_block * BLOCK_SIZE)) print('x:{}, y:{}; rgb:{}'.format(x_block, y_block, colour))
This would give you output like:
x:0, y:0; rgb:(65, 12, 11) x:0, y:1; rgb:(197, 56, 120) x:0, y:2; rgb:(245, 18, 90)
where x, y coordinates refer to blocks, not pixels.
thanks, i think that would work well enough
i'll save the python script for another time :)