7.3.5. RGBA Images of ubytes |
(lsh/libimage/rgbaimage.lsh) |

basic image processing on RGBA images where each pixel component is an unsigned byte.

7.3.5.0. rgbaimage |
(lsh/libimage/rgbaimage.lsh) |

a rgbaimage is an idx3 of ubytes intended to store images. The last dimension is 4, and contains the R, G, B, and Alpha channels respectively.

7.3.5.1. Geometric Transforms |
(lsh/libimage/rgbaimage.lsh) |

A few functions to enlarge, reduce, resize, and rotate images.

7.3.5.1.0. (rgbaim-resize im width height mode) |
(lsh/libimage/rgbaimage.lsh) |

resize an rgba 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

- if either
**width**or**height**is zero,**mode**is ignored.

- mode=0: fit the image into a
**width**by**height**frame while preserving the aspect ratio

- mode=1: scale the image to
**width**by**height**possibly changing the aspect ratio

- mode=2:
**width**and**height**are interpreted as scaling ratios

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

7.3.5.1.1. (rgbaim-enlarge in nlin ncol) |
(lsh/libimage/rgbaimage.lsh) |

enlarges image

7.3.5.1.2. (rgbaim-enlarge-into in out nlin ncol) |
(lsh/libimage/rgbaimage.lsh) |

enlarges image

7.3.5.1.3. (rgbaim-subsample in nlin ncol) |
(lsh/libimage/rgbaimage.lsh) |

subsamples image

7.3.5.1.4. (rgbaim-subsample-into in out nlin ncol) |
(lsh/libimage/rgbaimage.lsh) |

subsamples image

7.3.5.1.5. (rgbaim-rot90-left inp) |
(lsh/libimage/rgbaimage.lsh) |

rotate image

7.3.5.1.6. (rgbaim-rot90-right inp) |
(lsh/libimage/rgbaimage.lsh) |

rotate image

7.3.5.1.7. (rgbaim-rot180 inp) |
(lsh/libimage/rgbaimage.lsh) |

rotate image

7.3.5.1.8. (rgbaim-rot180-inplace in) |
(lsh/libimage/rgbaimage.lsh) |

in-place 180 degree rotation of an image (caution: input image is destroyed).

7.3.5.1.9. (rgbaim-crop in x y w h) |
(lsh/libimage/rgbaimage.lsh) |

crop rectangle (

7.3.5.1.10. (rgbaim-warp-quad in out background mode x1 y1 x2 y2 x3 y3 x4 y4 p1 q1 p3 q3) |
(lsh/libimage/rgbaimage.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: warp rgbaimage <in> through a geometric transformation that maps a quadrilateral into a rectangle (bilinear transform). The quadrilateral is specified by <x1> <y1> <x2> <y2> <x3> <y3> <x4> <y4> (points are numbered clockwise starting from upper left). The rectangle is specified by the upper left and lower right points which are respectively <p1><q1> and <p3><q3>. The result is put in <out>. Clipping is automatically performed. pixels outside of the bounds of <in> are assumed to have the value <background> (which must be an idx1 of ubyte of size 4). <mode>=0: no antialiasing, <mode>=1: antialiasing with bilinear interpolation (2 times slower).

7.3.5.1.11. (rgbaim-warp in out background pi pj) |
(lsh/libimage/rgbaimage.lsh) |

((-idx1- (-ubyte)) background): ((-idx3- (-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 integers idx whose dimensions must be identical to the first two dimensions of <out>. An output pixel at coordinate (x,y) takes the value of the input pixel at coordinate <pj[x,y]>,<pi[x,y]>. If the values in <pi> and <pj> are non integers the pixels are computed by bilinearly interpolating the input image. The <pi> and <pj> matrices contain 32-bit integers which are interpreted as 16 bit of integer part and 16 bits of fractinal part. Integers values are assumed to fall in the center of each pixel, so the upper left-hand corner of an image is at coordinate (-0.5, -0.5).

7.3.5.1.12. (rgbaim-warp-fast in out background pi pj) |
(lsh/libimage/rgbaimage.lsh) |

((-int-) background): ((-idx2- (-ubyte-)) in out): ((-idx2- (-int-)) pi pj): RETURNS: Null SIDE EFFECTS: <out> AUTHOR: Y. LeCun 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 This is essentially identical to rgbaim-warp, escept no bilinear interpolation is performed (only a nearest neighbor rule is used).

7.3.5.1.13. (rgbaim-rotscale src sx sy dst dx dy angle coeff bg) |
(lsh/libimage/rgbaimage.lsh) |

rotate, scale, and translate image

(let* ((w (idx-dim m 1)) (h (idx-dim m 0)) (wh (int-matrix 2)) (cxcy (float-matrix 2)) (bg (ubyte-matrix 4))) (rgbaim-rotscale-rect w h hotx-src hoty-src angle coeff wh cxcy) (let ((z (ubyte-matrix (wh 1) (wh 0) 4))) (rgbaim-rotscale m hotx-src hoty-src z (cxcy 0) (cxcy 1) angle coeff bg)))

7.3.5.1.14. (rgbaim-rotscale-rect w h cx cy angle coeff wh cxcy) |
(lsh/libimage/rgbaimage.lsh) |

Given an input image of width

7.3.5.1.15. Low-Level Geometric Transform Functions |
(lsh/libimage/rgbaimage.lsh) |

These are unlikely to be used directly by most users.

7.3.5.1.15.0. (rgbaim-interpolate-bilin background pin indimi indimj inmodi inmodj ppi ppj rez) |
(lsh/libimage/rgbaimage.lsh) |

Author(s): Y. LeCun

(-gptr- pin rez background): (-int- indimi indimj inmodi inmodj ppi ppj): SIDE EFFECTS: <rez> DESCRIPTION: returns a bilinearly interpolated RGBA 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.5.2. Color Processing |
(lsh/libimage/rgbaimage.lsh) |

7.3.5.2.0. (rgbaim-contbright in out c b) |
(lsh/libimage/rgbaimage.lsh) |

correct contrast and brightness of image

7.3.5.2.1. (rgbaim-luminance in out) |
(lsh/libimage/rgbaimage.lsh) |

compute luminance of each pixel and put result in image

7.3.5.2.2. (rgbaim-lum2rgba in out) |
(lsh/libimage/rgbaimage.lsh) |

transform a grey-level image

7.3.5.2.3. (rgbaim-uvw in out) |
(lsh/libimage/rgbaimage.lsh) |

transform an RGBA image into an UVWA image, where the V component contains the luminance information, and the U and W components collectively contain the chrominance information. In the UVW color coding scheme the euclidean distance is meant to reflect the subjective "perceptual" distance. See Digital Image Processing by W. Pratt, page 66.

7.3.5.2.4. (rgbaim-saturate in min max out) |
(lsh/libimage/rgbaimage.lsh) |

Saturate pixel component values in image

7.3.5.3. Blitting |
(lsh/libimage/rgbaimage.lsh) |

7.3.5.3.0. (rgbaim-blit x y in out) |
(lsh/libimage/rgbaimage.lsh) |

blit

7.3.5.3.1. (rgbaim-blitcolor x y in r g b out) |
(lsh/libimage/rgbaimage.lsh) |

blit color defined by

7.3.5.4. Histograms |
(lsh/libimage/rgbaimage.lsh) |

7.3.5.4.0. (rgbaim-histo32 rgbaim ppal count) |
(lsh/libimage/rgbaimage.lsh) |

compute histogram of image

7.3.5.4.1. Low-Level Histogram Functions |
(lsh/libimage/rgbaimage.lsh) |

7.3.5.4.1.0. (rgbaim-init-lum2rgb ) |
(lsh/libimage/rgbaimage.lsh) |

build a table of 32x32x32 elements containing RGB cell indices in ascending luminosity.

7.3.5.4.1.1. (rgbaim-lum2rgb n) |
(lsh/libimage/rgbaimage.lsh) |

converts a luminosity index to a 5-bit RGB cell number.

7.3.5.5. Various Unusual Subsampling Functions |
(lsh/libimage/rgbaimage.lsh) |

7.3.5.5.0. (rgbaim-subsample+ in nlin ncol) |
(lsh/libimage/rgbaimage.lsh) |

same as

7.3.5.5.1. (rgbaim-subsample-med3 rgbaim) |
(lsh/libimage/rgbaimage.lsh) |

subsample images by 3x3 using a median filter.

7.3.5.5.2. (rgbaim-med3-subopt rgbaim) |
(lsh/libimage/rgbaimage.lsh) |

3x3 subsampling using the median smart median optimised in C for 3x3 squares: 1.3 sec

7.3.5.5.3. (rgbaim-med3-slow rgbaim) |
(lsh/libimage/rgbaimage.lsh) |

3x3 subsampling using the median brute force median, with a 9 element quicksort