title: Bilinear image interpolation / scaling - A calculation example
body: <p>I would like to ask you about some bilinear interpolation / scaling details. Let's assume that we have this matrix:</p>
  
  <pre><code>|100 | 50 |
  |70  | 20 |
  </code></pre>
  
  <p>This is a 2 x 2 grayscale image.  Now, I would like scale it by factor of two and my matrix looks like this:</p>
  
  <pre><code>| 100   | f1 | 50 | f2 |
  | f3    | f4 | f5 | f6 |
  | 70    | f7 | 20 | f8 |
  </code></pre>
  
  <p>so if we would like to calculate <code>f4</code>, the calculation is defined as</p>
  
  <pre><code>f1 = 100 + 0.5(50 - 100) = 75
  f7 = 70 +  0.5(20 - 70) = 45
  </code></pre>
  
  <p>and now finally:</p>
  
  <pre><code>f4 = 75 + 0.5(45 - 75) = 60
  </code></pre>
  
  <p>However, I can't really understand what calculations are proper for <strong>f3</strong> or <strong>f1</strong></p>
  
  <p>Do we do the bilinear scaling in each direction separately?  Therefore, this would mean that:</p>
  
  <pre><code>f3 = 100 + 0.5(70 - 100) = 85
  f1 = 100 + 0.5(50 - 100) = 75
  </code></pre>
  
  <p>Also, how should I treat <strong>f2, f6, f8</strong>. Are those points simply being copied like in the nearest neighbor algorithm?</p>