The Image structure


Synopsis

signature IMAGE
structure Image : IMAGE
The Image structure implements a parameterized image type and general image functions. Substructures implement processing and analysis functions specific to each of three types of images: Grey, Color, and Complex.

Interface

type 'a image = 'a Array2.array

val image : int * int * 'a -> 'a image

val fromList : 'a list list -> 'a image
val toList : 'a image -> 'a list list

val tabulate : int * int * (int * int -> 'a) -> 'a image
val tabulateFilter : int * int * (int * int -> 'a) -> 'a image

val sub : 'a image * int * int -> 'a

val nRows : 'a image -> int
val nCols : 'a image -> int

val row : 'a image * int -> 'a vector
val column : 'a image * int -> 'a vector

val mapi : (int * int * 'a -> 'b) -> 'a image -> 'b image
val map : ('a -> 'b) -> 'a image -> 'b image

val foldi : (int * int * 'a * 'b -> 'b) -> 'b -> 'a image -> 'b
val fold : ('a * 'b -> 'b) -> 'b -> 'a image -> 'b

val crop : ('a image * int * int * int * int) -> 'a image
val pad : 'a -> ('a image * int * int) -> 'a image

val binop : ('a * 'b -> 'c) -> 'a image * 'b image -> 'c image

val transpose : 'a image -> 'a image

val flip : 'a image -> 'a image
val flop : 'a image -> 'a image

val rotateCW : 'a image -> 'a image
val rotateCCW : 'a image -> 'a image

val downSampleRows : 'a image -> 'a image
val downSampleCols : 'a image -> 'a image
val downSample : 'a image -> 'a image

val upSampleRows : 'a -> 'a image -> 'a image
val upSampleCols : 'a -> 'a image -> 'a image
val upSample : 'a -> 'a image -> 'a image

val leftToRight : 'a image list -> 'a image
val topToBottom : 'a image list -> 'a image

structure Grey : IMAGE_GREY
structure Color : IMAGE_COLOR
structure Complex : IMAGE_COMPLEX

Details

type 'a image = 'a Array2.array
The polymorphic image type, implemented as an Array2.array.

val image : rows int * columns int * value 'a -> 'a image
Construct an image with the specified number of rows and columns with all pixels assigned value.

val fromList : 'a list list -> 'a image
Construct an image from a list. Each "inner" list is interpreted as one row of the resultant image. For example, given the list [[1.0,2.0],[3.0,4.0]] this function will construct an image whose first row contains 1.0 and 2.0 and whose second rows contains 3.0 and 4.0.

val toList : 'a image -> 'a list list
Construct a list of lists from an image, where each "inner" list is a row of the input image.

val tabulate : rows int * columns int * f (int * int -> 'a) -> 'a image
Construct an image with the specified number of rows and columns with the pixel at (i,j) assigned the value returned by applying f to (i,j). The function is applied in row-major order (Array2.RowMajor).

val tabulateFilter : rows int * columns int * f (int * int -> 'a) -> 'a image
Similar to tabulate, except that to match the periodicity of the 2D discrete Fourier spectrum, the value of the pixel at location (i, j) is computed by applying f to x and y, where x equals i if i is less than m/2 and i - m otherwise, and y equals j if j is less than n/2 and j - n otherwise. For example, the value at location (0, 0) is the result of applying f to 0 and 0, the value at (m-1, n-1) is the result of applying f to -1 and -1.

val sub : 'a image * i int * j int -> 'a
Return the value of the pixel at (i,j).

val nRows : 'a image -> int
Return the number of rows in an image.

val nCols : 'a image -> int
Return the number of columns in an image.

val row : 'a image * n int -> 'a vector
Return the nth row of an image.

val column : 'a image * n int -> 'a vector
Return the nth column of an image.

val mapi : f (int * int * 'a -> 'b) -> 'a image -> 'b image
val map : f ('a -> 'b) -> 'a image -> 'b image
Map the function f to an image in row-major order (Array2.RowMajor). The function (map f) is equivalent to (mapi (fn (_,_,x) => f x)).

val foldi : (int * int * 'a * 'b -> 'b) -> 'b -> 'a image -> 'b
val fold : ('a * 'b -> 'b) -> 'b -> 'a image -> 'b
Fold across an image. This is always implemented row-major order (Array2.RowMajor). The function (fold f) is equivalent to (foldi (fn (_,_,a,b) => f (a,b))).

val crop : ('a image * i0 int * j0 int * n int * m int) -> 'a image
Return an image with m rows and n columns, cropped from the input image starting at (i0,j0).

val pad : zero 'a -> (img 'a image * m int * n int) -> 'a image
Returns an image with m rows and n columns, where the value at (i,j) is the same as img at (i,j) if i is less than the number of rows in img and j is less than the number of columns in img, and zero otherwise.

val binop : ('a * 'b -> 'c) -> 'a image * 'b image -> 'c image
Construct an image by pixel-wise applying a binary operator to two images.

val transpose : 'a image -> 'a image
Transpose an image as if it were a matrix.

val flip : 'a image -> 'a image
Flip an image vertically.

val flop : 'a image -> 'a image
Flip an image horizontally.

val rotateCW : 'a image -> 'a image
Rotate an image 90 degrees clockwise.

val rotateCCW : 'a image -> 'a image
Rotate an image 90 degrees counter-clockwise.

val downSampleRows : 'a image -> 'a image
Discard even rows of an image.

val downSampleCols : 'a image -> 'a image
Discard even rows of an image.

val downSample : 'a image -> 'a image
Discard even rows and columns of an image.

val upSampleRows : zero 'a -> 'a image -> 'a image
Construct an image with twice as many rows, where the pixel at (i*2,j) is the value of the input image at (i,j), and all other pixels are zero.

val upSampleCols : zero 'a -> 'a image -> 'a image
Construct an image with twice as many columns, where the pixel at (i,j*2) is the value of the input image at (i,j), and all other pixels are zero.

val upSample : zero 'a -> 'a image -> 'a image
Construct an image with twice as many rows and columns, where the pixel at (i*2,j*2) is the value of the input image at (i,j), and all other pixels are zero.

val leftToRight : 'a image list -> 'a image
Concatenate images from left to right.

val topToBottom : 'a image list -> 'a image
Concatenate images from top to bottom.


Last modified: Tue Feb 14 11:48:00 Mountain Standard Time 2006
rlpm [ -at- ] cs.unm.edu