7.3.8. Greyscale Images of shorts
(lsh/libimage/shimage.lsh)


functions to manipulate images where each pixel is a 16-bit short.

7.3.8.0. shimage
(lsh/libimage/shimage.lsh)


a shimage is an idx2 of shorts intended to store image. the pixel values are interpreted as fixed point integers, with the upper byte being the integer part, and the lower byte being the fractional part.

7.3.8.1. (shimage2flt in out)
(lsh/libimage/shimage.lsh)


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


7.3.8.2. (flt2shimage in out)
(lsh/libimage/shimage.lsh)


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


7.3.8.3. (shimage2fltimage in out bkgd ink)
(lsh/libimage/shimage.lsh)


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


7.3.8.4. (fltimage2shimage in out bkgd ink)
(lsh/libimage/shimage.lsh)


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


7.3.8.5. (shim-interpolate-bilin background pin indimi indimj inmodi inmodj ppi ppj)
(lsh/libimage/shimage.lsh)


(-gptr- pin):
(-int-  background indimi indimj inmodi inmodj ppi ppj):
RETURNS: (-short-)
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 shorts, 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.8.6. (shim-warp in out background pi pj)
(lsh/libimage/shimage.lsh)


((-int-) background):
((-idx2- (-short-)) 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 shorts. <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.8.7. (shim-warp-fast in out background pi pj)
(lsh/libimage/shimage.lsh)


((-int-) background):
((-idx2- (-short-)) 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 shorts. <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-shimage, except no antialiasing
is performed (it goes a lot faster, but is not nearly as nice).


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


((-flt-) x1 y1 x2 y2 x3 y3 x4 y4 p1 q1 p3 q3):
((-int-) background mode):
((-idx2- (-short-)) in out):
RETURNS: Null
SIDE EFFECTS: <out>
AUTHOR: Y. LeCun
COMPILABLE: Yes
DESCRIPTION:
transforms shimage <in> (idx2 of short) 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 short).  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.