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.
<
Just for fun, I tackled this with ImageMagick - which is also callable from Python...
First off, I create a little custom palette to match your colours - your white is not very white and your green is different from ImageMagick's idea of green so I used hex for them instead of colour names.
convert xc:black xc:red xc:"rgb(200,200,200)" xc:"rgb(168,228,23)" xc:orange +append palette.png
If I scale that palette up, it looks like this:
Then I resize your image down to 4x4 and map the result to the custom palette and scale it back up so you can see it like this:
convert lego.jpg -resize 4x4! +dither -remap palette.png -scale 1600 result.png
and here is the result
The white is off to match the "white" in your original.