14. Oktober 2010

# Nearest-Neighbor-Resampling in Matlab

This article shows the derivation of an algorithm for resizing images in Matlab, using nearest-neighbor interpolation. Scaling an image is mathematically just multiplying image coordinates by a scaling factor. Surprisingly, when dealing with digital images, the scaling process becomes a little bit more complex.

`jea_pygments_txp: File 'resample.m' does not exist.`

How to find this arithmetic expression? Step by step.

Convert a 1-based index i to a 0-based index i’  Convert a 0-based index i’ to a Cartesian coordinate

The first pixel has coordinate 0.5, the next pixel 1.5 and so on. This provides
consistent spacing between pixels and follows the standard image representation
on screens and other media.  Scale  Chaining the transformations together

Now, given an 1-based index i_f from the input image, how to calculate the corresponding 1-based index i_g in the output image? By chaining the transformations together. By inverting the composite function, we obtain the sought-after function We can now plug in the function definitions Compare this expression with the algorithm.