'How can I resize an image without using .resize() in python PIL
I have the enlarge ratio provided, like two times in width, three times in height.
Here's my thought, I want to go through each pixel in the image, enlarge all of them by ratio and put them in a new created picture.
Solution 1:[1]
Well, your thought is the first step. There is some other steps. The most important step is interpolation.
For example, if you want to enlarge a image with 2 pixels in width, 2 pixels in height to 4 pixel in width and height. As your thought, you should let
new_img[0][0] = old_img[0][0]
new_img[2][0] = old_img[1][0]
new_img[0][2] = old_img[0][1]
new_img[2][2] = old_img[1][1]
But only 4 pixels' value are assigned, what is the value of the other 12 pixels? You have to provide an algorithm to interpolate.
You can find more information from Wikipedia.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hugo |
