I am working on a project where I want to take a picture of a colored grid as an input (made with Lego bricks in this example) and return a much smaller modified picture.
<
Pixelator does the trick. It is a package based off or rr-
s answer. It also has some added benefits for AI and ML applications.
In bash
pip install pixelator
in python
from pixelator import pixelator
palette = [
(45, 50, 50), #black
(240, 68, 64), #red
(211, 223, 223), #white
(160, 161, 67), #green
(233, 129, 76), #orange
]
sensitivity_multiplier = 10
size = (4,4)
output=pixelator(
in_path='./images/input.jpg',
palette=palette,
size=size,
sensitivity_multiplier=sensitivity_multiplier
)
output.resize_out_img().save_out_img(path='./images/output.jpg', overwrite=True)