RESAMPLING OF 2D/3D IMAGES
A small library (written in C)
allowing 2D or 3D image resampling using a 4x4 matrix.
The value of a point in the result image is estimated
is available by
for non-commercial uses only.
- either by [bi|tri]linear interpolation,
- or by using the value of the nearest point.
| Original grey level image |
A 4 by 4 transformation matrix M (with homogenous coordinates) is of the form
The Rij define an affine matrix (rotation in case
of rigid transformation),
while the Ti define a translation vector.
The transformation of a point M = (x,y,z) into M' =
is done using
which is equivalent to
The principle of resampling is then to compute, for each point (of
integer coordinates) in the result image its correspondant
(of real coordinates)
in the original image, and to estimate the grey level value of the
correspondant. Thus, the transformation from the original image into
the result image is the inverse of the given matrix.
Consider the matrix
| M =
It correspond to a 2D rigid transformation with a rotation of 30
degrees (X axis is from left to right, Y axis is from top to bottom)
of center (127,127) (invariant point for the transformation).
Using directly this matrix with the resampling program
yields a rotation of -30 degrees as shown below.
| M =
By inverting the matrix, one may obtained the desired 30 degrees
%test-reech-pnm greg-rmn.pgm greg-rmn-reech1.ppm -mat matrix.example
%test-reech-pnm greg-rmn.pgm greg-rmn-reech2.ppm -mat
This option is quite useful when one want to resample labels images
(see example in the connected components page).
| Interpolation using the nearest
|Command lines as the same as above except that the
-nearest has been added
| Initial image|
| Linear resampling|
| New grey levels appear at borders|
| Nearest neighbor resampling|
| Only the original grey levels are used|
Last modified: Mon Jun 26 10:43:00 MET DST 2000