7.3.7. Greyscale Images of ubytes
(lsh/libimage/ubimage.lsh)


linear coordinate transform using bilinear interpolation.



7.3.7.0. ubimage
(lsh/libimage/ubimage.lsh)


a ubimage is an idx2 of ubytes intended to store image.

7.3.7.1. (ubimage2flt in out)
(lsh/libimage/ubimage.lsh)


((-idx2- (-ubyte-)) in):
((-idx2- (-flt-)) out):
RETURNS: Null
SIDE EFFECTS: <out>
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
Converts ubimage <in> into idx2 of flt <out>.
Values are scaled down by 1/255.


7.3.7.2. (flt2ubimage in out)
(lsh/libimage/ubimage.lsh)


((-idx2- (-ubyte-)) out):
((-idx2- (-flt-)) in):
RETURNS: Null
SIDE EFFECTS: None
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
converts flt idx2 <in> to an ubimage <out>.
a pixel values are scaled up by 255.


7.3.7.3. (ubimage2fltimage in out bkgd ink)
(lsh/libimage/ubimage.lsh)


((-idx2- (-ubyte-)) in):
((-idx2- (-flt-)) out):
((-flt-) bkgd ink):
RETURNS: Null
SIDE EFFECTS: <out>
AUTHOR: C. Burges
COMPILABLE: Yes
DESCRIPTION:
Generalization of Yann's ubimage2flt for arbitrary ink and background.
Converts ubimage <in> into idx2 of flt <out>.


7.3.7.4. (fltimage2ubimage in out bkgd ink)
(lsh/libimage/ubimage.lsh)


((-idx2- (-flt-)) in):
((-idx2- (-ubyte-)) out):
((-flt-) bkgd ink):
RETURNS: Null
SIDE EFFECTS: <out>
AUTHOR: C. Burges
COMPILABLE: Yes
DESCRIPTION:
Generalization of Yann's flt2ubimage for arbitrary ink and background.
Converts flt idx2 <in> to a ubimage <out>.


7.3.7.5. (ubim-resize im width height mode)
(lsh/libimage/ubimage.lsh)


resize a greyscale image to any size using bilinear interpolation Appropriate local averaging (smoothing) is performed for scaling factors smaller than 0.5. If one of the desired dimensions is 0, an aspect-ratio-preserving scaling is performed on the basis of the other dimension. When both width and height are non zero, the last parameter, mode determines how they are interpreted.

The sizes of the output image are rounded to nearest integers smaller than the computed sizes, or to 1, whichever is largest.



7.3.7.6. (ubim-subsample in nlin ncol)
(lsh/libimage/ubimage.lsh)


subsamples image in with integer ratios nlin (vertical) ncol (horizontal). the subsampled image is returned. The horizontal (resp. vertical) size of the returned image is equal to the integer part of the horizontal (resp vertical) size of in divided by ncol (resp nlin ).

returns (copy-matrix in ) when subsample rate is 1



7.3.7.7. (ubim-zoom ubim zoomx zoomy)
(lsh/libimage/ubimage.lsh)


Zoom an ubyte image ubim by the given integer zoom factors.

7.3.7.8. (ubim-invert im)
(lsh/libimage/ubimage.lsh)


reverse polarity of an ubimage. each pixel is replaced by 255 minus itself

7.3.7.9. (ubim-interpolate-bilin background pin indimi indimj inmodi inmodj ppi ppj)
(lsh/libimage/ubimage.lsh)


(-gptr- pin):
(-int-  background indimi indimj inmodi inmodj ppi ppj):
RETURNS: (-ubyte-)
SIDE EFFECTS: None
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
returns a bilinearly interpolated pixel value for coordinate
<ppi> <ppj>. The image data is pointed to by <pin>, with 
<indimi> <indimj> <inmodi> <inmodj> being the dimensions and modulos.
This function clips automatically if <ppi> <ppj> are outside of the
bounds by assuming the outside values are equal to <background>.
pixel values are ubytes, while coordinates are 32 bit fixed point
with 16 bit integer part and 16 bit fractional part.
The function does not use floating point arithmetics.


7.3.7.10. (ubim-warp in out background pi pj)
(lsh/libimage/ubimage.lsh)


((-int-) background):
((-idx2- (-ubyte-)) in out):
((-idx2- (-int-)) pi pj):
RETURNS: Null
SIDE EFFECTS: <out> 
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
Warps an image using <pi> and <pj> as tabulated coordinate transforms.
<in> and <out> are idx2 of ubytes. <background> is the value assumed outside
of the input image. <pi> and <pj> are tabulated coordinates which can
be filled up using compute-bilin-transform or similar functions.
Pixel values are antialiased using bilinear interpolation.


7.3.7.11. (ubim-warp-fast in out background pi pj)
(lsh/libimage/ubimage.lsh)


((-int-) background):
((-idx2- (-ubyte-)) in out):
((-idx2- (-int-)) pi pj):
RETURNS: Null
SIDE EFFECTS: <out>
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
Warps an image using <pi> and <pj> as tabulated coordinate transforms.
<in> and <out> are idx2 of ubytes. <background> is the value assumed outside
of the input image. <pi> and <pj> are tabulated coordinates which can
be filled up using compute-bilin-transform or similar functions.
This is essentially identical to warp-ubimage, except no antialiasing
is performed (it goes a lot faster, but is not nearly as nice).


7.3.7.12. (ubim-warp-quad in out background mode x1 y1 x2 y2 x3 y3 x4 y4 p1 q1 p3 q3)
(lsh/libimage/ubimage.lsh)


((-flt-) x1 y1 x2 y2 x3 y3 x4 y4 p1 q1 p3 q3):
((-int-) background mode):
((-idx2- (-ubyte-)) in out):
RETURNS: Null
SIDE EFFECTS: <out>
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
transforms ubimage <in> (idx2 of ubyte) mapping quadrilateral <x1> <y1> <x2>
<y2> <x3> <y3> <x4> (points are numbered clockwise starting from upper left)
to rectangle whose upper left and lower right points are <p1><q1>, <p3><q3>.
result is put in <out> (idx2 of ubyte).  Clipping is automatically performed.
pixels outside of the bounds of <in> are assumed to have the value
<background>.  <mode>=0: no antialiasing, <mode>=1: antialiasing with
bilinear interpolation (2 times slower).  execution time on sparc 10 is about
5 ms in mode 0 and 10 ms in mode 1 for a 32x32 target image.