title: How the nearest-neighbor interpolation works on 2D (upscaling)
body: <p>I have a small doubt about the <a href="https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation" rel="nofollow noreferrer">nearest-neighbor interpolation</a> method:</p>
  
  <p>Suppose we have a grayscale image of size 2x2 pixels, which can be represented by the following matrix:</p>
  
  <pre><code>[100, 120]
  [080, 100]
  </code></pre>
  
  <p>And we want to resize it to the size of 3x3 pixels:</p>
  
  <pre><code>[100, X, 120]
  [  X, X,   X]
  [080, X, 100]
  </code></pre>
  
  <p>How will the missing data points (pixels) be filled?</p>
  
  <p>Will it just replicate the first nearest data point (pixel)?
  For example:</p>
  
  <pre><code>[100, 100, 120]
  [100, 100, 120]
  [080, 080, 100]
  </code></pre>
  
  <p>Or, will it calculate the average between the two nearest neighbors?
  For example:</p>
  
  <pre><code>[100, 110, 120]
  [090, 100, 110]
  [080, 090, 100]
  </code></pre>
  
  <p>Thanks</p>