A snipping tool that resizes the image intelligently using content aware scaling
The inspiration came from cropping images for training data. I wanted a way to avoid squishing image, but still preserve the features.
The tool is implemented with the algorithm described in this paper
GUI built with PyQt5
This application allows users to crop image and decide the percentage of the original size they want to reduce it to while still preserving the prominent features
The algorithm creates a mapping of weights on each pixel by summing the absolute value of the partial derivative of the images in x-axis and y-axis. It is done by convoling against the image with a 3x3 sobel filter
The formula to calculate the weight is
After obtaining the weight mapping, the algorithm finds the minimum path from top to bottom. Remove said path and repeating the same process will result in an image that preserves all the prominent features.
For more information please see this blog.
Example (50% reduction):
Because the algorithm looks for prominent features in the image, if you were to crop an image of a face and reduce it by 50%. If it thinks the eyes and mouth are more outlined than the shape of face. The resulting picture may make you look like an alien. This may be not be a good thing if you are trying to make an instagram post. However, this could be potentially used in data augmentation for neural networks.