Search code examples
mathlogarithmexponent

Multiply a number by a ratio n times to achieve a desired number


I'm trying to scale an image down in steps so as to avoid artifacts. I have an 800 square pixel image that needs to be scaled down to 100 square pixels. I want to perform the scaling in a variable number of iterations. So lets say that I want to go from 800 to 100 in 3 iterations. How do I find the ratio to apply to the image each time to achieve the desired size?


Solution

  • If you want to achieve a final ratio R, in N steps, then the ratio at each step would be the N-th root of R, or equivalently, R^(1/N). For your example, R=1/8, and N=3, so the ratio at each step would be (1/8)^(1/3), or 1/2.