next up previous contents index
Next: fdirspline Up: Reference Previous: czoom   Contents   Index

fcrop

$ \bigcirc$Name


fcrop image croping (with zoom) using interpolation




$ \bigcirc$Command Synopsis


fcrop [-x sx] [-y sy] [-z z] [-b bg] [-o o] [-p p] in out X1 Y1 X2 Y2



-x sx : force x-size of output image

-y sy : force y-size of output image

-z z : zoom factor (default 1.0)

-b bg : background grey value, default: 0.0

-o o : order: 0,1=linear,-3=cubic,3,5..11=spline, default 3

-p p : Keys' parameter (when o=-3), in [-1,0], default -0.5

in : input Fimage

out : output Fimage

X1 : upleft corner

Y1 : upleft corner

X2 : downright corner

Y2 : downright corner




$ \bigcirc$Function Summary


Fimage fcrop (in , out , sx , sy , z , bg , o , p , X1 , Y1 , X2 , Y2 )

Fimage in , out ;

float *sx , *sy , *z , *p , *bg , X1 , Y1 , X2 , Y2 ;

int *o ;




$ \bigcirc$Description


This module allows to extract a part of an image and to resize it to the desired dimensions. This operation is realized using an interpolation [TBU99][UAE91] that can be chosen with the -o option. The image is assumed to be equal to a constant value bg (set with the -b option) outside its boundaries. Moreover, it is assumed that the image has been sampled at the center of each pixel; that is, the value in(i, j) corresponds to the exact value of the continuous image at point (i + 1/2, j + 1/2). The subpart of the original image that has to be extracted is defined by the rectangle (X1, Y1) - (X2, Y2). The user can choose a magnification factor z (using -z option), which will set the output image dimensions by rounding to the nearest integer the magnified input dimensions. Another possibility is to choose the output dimensions sx and sy (using the -x and -y options); in that case, the magnification factor will be computed accordingly. If only one output dimension is specified, then the other one will be set in order to preserve the aspect ratio of the original region.


-o option (interpolation order) :

All interpolation schemes described below are separable, so they can be applied separately on each coordinate. Direct interpolation of a discrete set of value uk is defined by

u(x) = $\displaystyle \sum_{k}^{}$uk $\displaystyle \varphi$(x - k + 1/2),

where $ \varphi$ is the interpolation function.

$ \bullet$ 0: nearest-neighbor interpolation, which corresponds to direct interpolation with a B-spline of order 0,

$\displaystyle \beta^{0}_{}$(x) = $\displaystyle \left\{\vphantom{\begin{array}{lcl}
1 & & -1/2 \leq \vert x\vert < 1/2 \\
0 & & {\mathrm else}.
\end{array}}\right.$$\displaystyle \begin{array}{lcl}
1 & & -1/2 \leq \vert x\vert < 1/2 \\
0 & & {\mathrm else}.
\end{array}$

$ \bullet$ 1: bilinear interpolation, which corresponds to direct interpolation with a B-spline of order 1,

$\displaystyle \beta^{1}_{}$(x) = $\displaystyle \left\{\vphantom{\begin{array}{lcl}
1-\vert x\vert & & 0 \leq \vert x\vert \leq 1 \\
0 & & 1 \leq \vert x\vert.
\end{array}}\right.$$\displaystyle \begin{array}{lcl}
1-\vert x\vert & & 0 \leq \vert x\vert \leq 1 \\
0 & & 1 \leq \vert x\vert.
\end{array}$

$ \bullet$ -3: direct interpolation with cubic Keys' function, defined by

$\displaystyle \varphi_{a}^{}$(x) = $\displaystyle \left\{\vphantom{\begin{array}{lcl}
(a+2)\vert x\vert^3 - (a+3)\v...
... 1 \leq \vert x\vert \leq 2 \\
0 & & 2 \leq \vert x\vert.
\end{array}}\right.$$\displaystyle \begin{array}{lcl}
(a+2)\vert x\vert^3 - (a+3)\vert x\vert^2+1 & ...
...rt-4 & & 1 \leq \vert x\vert \leq 2 \\
0 & & 2 \leq \vert x\vert.
\end{array}$

This function is C1 and depends on a parameter a $ \in$ [- 1, 0] that can be set with the -p option. Its default value, -1/2, ensures an approximation order equal to 3 (instead of 2 for other values).

$ \bullet$ n=3,5,7,9,11: indirect interpolation with the B-spline of order n

$\displaystyle \beta^{n}_{}$(x) : = $\displaystyle \beta^{0}_{}$*$\displaystyle \beta^{{n-1}}_{}$(x) = $\displaystyle \sum_{{k=0}}^{{n+1}}$$\displaystyle {\frac{{(-1)^k(n+1)}}{{(n+1-k)!k!}}}$$\displaystyle \left(\vphantom{\frac{n+1}2+x-k}\right.$$\displaystyle {\frac{{n+1}}{2}}$ + x - k$\displaystyle \left.\vphantom{\frac{n+1}2+x-k}\right)^{n}_{+}$,

where (x)n+ = $ \big($max(0, x)$ \big)^{n}_{}$. Contrary to direct interpolation, indirect interpolation uses coefficients ck to define

u(x) = $\displaystyle \sum_{k}^{}$ck $\displaystyle \varphi$(x - k + 1/2).

This set of coefficients (ck) must be computed first in order to ensure that u(k + 1/2) = uk. For B-spline interpolation, this operation is performed by the finvspline module. Note that $ \beta^{n}_{}$ is of class Cn-1. In particular, the cubic spline performs a better (indirect) interpolation (C2 and approximation order of 4) than the Keys cubic (direct) interpolant (C1 and approximation order of 3).


NB : calling this module with out=in is possible




$ \bigcirc$See Also


finvspline.

cccrop, fkview, fzoom, llview.


$ \bigcirc$Version 1.0


Last Modification date : Thu Nov 29 20:23:56 2001


$ \bigcirc$Author


Lionel Moisan






next up previous contents index
Next: fdirspline Up: Reference Previous: czoom   Contents   Index
mw 2004-05-05