skip to Main Content

My algorithm for scaling a bitmap b of size w1 × h1 to a bitmap of size w2 × h2:

  1. scale b to a bitmap b1 of size lcm(w1, w2) × lcm(h1, h2) using nearest-neighbor scaling algorithm;
  2. partition b1 to a grid that have w2 columns and h2 rows where all columns have the same width and all rows have the same height;
  3. set the color of every pixel in b1 to the average color of the pixel’s belonging grid cell;
  4. scale the modified b1 to a bitmap b2 of size w2 × h2 using nearest-neighbor scaling algorithm;
  5. The bitmap b2 is the result of this algorithm.

The algorithm above is not the most efficient one to get the result. I only use it to describe the effect of the scaling algorithm (and I can do it in Photoshop instead of writing a program). Is there a known algorithm that produces the same result as mine?

2

Answers


  1. Chosen as BEST ANSWER

    I found a detailed description here: http://entropymine.com/imageworsener/pixelmixing/.

    It’s sometimes called pixel mixing, pixel averaging, or area map, among other things.


  2. The problem with your algorithm is that it will take a lot of memory. As an example, if you scale from a size of 11×11 to 13×13, the least common multiple (lcm) of 11 and 13 is 143. You will therefore create a 143×143 image, and then reduce it to 13×13.

    As an alternative, have a look at “bilinear interpolation”: https://en.wikipedia.org/wiki/Bilinear_interpolation (this article also gives other methods in the “See also” section).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search