While search openCV tutorial online few days back, I came across a post to create dot pattern image using OpenCV & C++. I’ve follow the tutorial and created 1 using Python-OpenCV.
It’s working and I’ve taken 1 more step to turn the code into Python 3 (because currently you can only use OpenCV with Python 2) and uses PIL (pillow) instead of OpenCV for image manipulation.
I’ve shared my code on Gist. The process is quite simple, first you need to create a mask image and fill it up with dots. After that, the original image is pixelize with the size of the dots. In my code, the size of the box is defined at line 7 (pixelization_length).
The main loop starting line 19 draw the dots and calculate average value for 3 channels (RGB) for pixelization.
Images below shows the mask and pixelized image output.
Line 48 paste the mask on top of the pixelized image. Here’s the result
You can try with different pixelization_length. Here’s another try on a cat image with length of 8.
Happy Trying 😉