Next: , Previous: , Up: Image Processing   [Contents][Index]


Transform

The Guile-CV procedures and methods to transform images.

Procedures

im-rgba->rgb
im-rgba->gray
im-rgb->gray
im-resize
im-resize-channel
im-rotate
im-rotate-channel
im-flip
im-flip-channel
im-invert
im-invert-channel
im-transpose
im-transpose-channel
im-complement
im-clip
im-clip-channel
im-crop
im-crop-channel
im-crop-size
im-padd
im-padd-channel
im-padd-size
im-local-minima
im-local-minima-channel
im-local-maxima
im-local-maxima-channel
im-fft
im-fft-channel
im-fft-inverse
im-fft-inverse-channel
im-fcc
im-fcc-channel
im-fncc
im-fncc-channel
Procedure: im-rgba->rgb image [#:bg '(0.0 0.0 0.0)]
Procedure: im-rgba->gray image [#:bg '(0.0 0.0 0.0)]
Procedure: im-rgb->gray image

Returns a new RGB or GRAY image.

In the RGBA case, image channels are first normalized. The new RGB channels are obtained by applying the following pseudo code algorithm:

R = (((1 - Source.A) * BG.R) + (Source.A * Source.R)) * 255.0
G = (((1 - Source.A) * BG.G) + (Source.A * Source.G)) * 255.0
B = (((1 - Source.A) * BG.B) + (Source.A * Source.B)) * 255.0
Procedure: im-resize image new-width new-height [#:i-mode 'bilinear]
Procedure: im-resize-channel channel width height new-width new-height [#:i-mode 'bilinear]

Returns a new image or chanbnel resized to new-width, new-height.

The interpolation mode #:i-mode, can be one of:

none
bilinear
biquadratic
bicubic
? (fixme)
Procedure: im-rotate image angle [#:i-mode 'bilinear]
Procedure: im-rotate-channel channel width height angle [#:i-mode 'bilinear]

Returns a new image or channel rotated by angle.

The angle is in degrees: +/-[0.0 360.0].

It is neccessary, for rotations other than multiples of 90°, to recalculate the target coordinates, since after the rotation, they might be floats. The ’next neighbor’ interpolation possible modes, #:i-mode, are:

bilinear
biquadratic
bicubic
? (fixme)
Procedure: im-flip image plane
Procedure: im-flip-channel channel width height plane

Returns a new image or channel flipped according to the selected plane.

Valid flipping plane values are:

hori horizontal
vert vertical
both
Procedure: im-invert image
Procedure: im-invert-channel channel width height

Returns a new inversed image or channel.

Calculating the inverse of an image or a channel consist of applying the exponent function, expt, to all pixel values, raising them to the power of -1.

Procedure: im-transpose image
Procedure: im-transpose-channel channel width height

Returns a new tranposed image or channel.

Transposing an image or a channel consist of flipping it over its main diagonal. In the transposed result, switched in size, row values are the original column values and column values are the original row values.

Procedure: im-complement image

Returns a new image.

This procedure computes the mathematical complement of image, which for Guile-CV means that for each pixel of each channel, the new value is (- 255.0 pixel-value).

Procedure: im-clip image [#:lower 0.0] [#:upper 255.0]
Procedure: im-clip-channel channel width height [#:lower 0.0] [#:upper 255.0]

Returns a new clipped image or channel.

Clipping an image or a channel consist of replacing all pixel values below lower by the lower value and all pixel values above upper by the upper value.

Procedure: im-crop image left top right bottom
Procedure: im-crop-channel channel width height left top right bottom [#:new-w #f] [#:new-h #f]

Returns a new image, resulting of the crop of image at left, top, right and bottom.

Procedure: im-crop-size width height left top right bottom

Returns a list, (new-width new-height).

Given the original image width and height, this procedure checks that left, top, right and bottom are valid and return a list, (new-width new-height), otherwise, it raises an error.

Procedure: im-padd image left top right bottom [#:color '(0.0 0.0 0.0)]
Procedure: im-padd-channel channel width height left top right bottom [#:new-w #f] [#:new-h #f] [#:value 0.0]

Returns a new image or channel, respectively padding image or channel by left, top, right and bottom pixels initialized respectively to color or value. Note that when im-padd is called upon a GRAY image, color is reduced to its corresponding gray value:

(/ (reduce + 0 color) 3)
Procedure: im-padd-size width height left top right bottom

Returns a list, (new-width new-height).

Given the original image width and height, this procedure checks that left, top, right and bottom are >= 0 and return a list, (new-width new-height), otherwise, it raises an error.

Procedure: im-local-minima image [#:threshold +float-max+]
Procedure: im-local-maxima image [#:threshold (- +float-max+)]
Procedure: im-local-minima-channel channel width height [#:threshold +float-max+]
Procedure: im-local-maxima-channel channel width height [#:threshold (- +float-max+)]

All local mnima and maxima related procedures also accept the following additional optional keyword arguments: [#:con 8] [#:marker 1.0] [#:borders? #f] [#:plateaus? #f] [#:epsilon 1.0e-4]

Returns a new image or channel.

Finds the local minima or maxima in image or channel. Local minima or maxima are defined as ‘points’ that are not on the borders (unless #:borders? is #t), and whose values are lower or higher, respectively, then the values of all direct neighbors. In the result image or channel, these points are marked using the #:marker value (all other pixels values will be set to 0).

By default, the algorithm uses 8-connectivity to define a neighborhood, which can be changed passing the optional keyword argument #:con, which can be either 4 or 8.

The #:threshold optional keyword argument can be used to discard minima and maxima whose (original pixel) value is not below or above the threshold, respectively. Both default values depend on +float-max+, which is defined (and so is +float-min+) using the corresponding limit value as given by the C float.h header.

The #:plateaus? optional keyword argument can be used to allow regions of ‘constant’ (original pixel) value whose neighbors are all higher (minima) or lower (maxima) than the value of the region. Tow pixel values are considered part of the same region (representing the same ‘constant’ value) if the absolute value of their difference is <= to #:epsilon.

Notes:

  • If you want to know how many minima or maxima were found, use im-reduce upon the result;
  • If you are interested by the original minima or maxima pixel values, Use im-times between the original image and the result.
Procedure: im-fft image
Procedure: im-fft-channel channel width height

Returns two images or channels.

Computes and returns the Fast Fourier Transform21 of the image or channel. It returns two values, images or channels: the first contains the real part and the second the imaginary part of the transformation.

Procedure: im-fft-inverse real imaginary
Procedure: im-fft-inverse-channel real-channel imaginary-channel width height

Returns two images or channels.

Computes and returns the inverse Fast Fourier Transform given its real and imaginary or real-channel and imaginary-channel parts. It returns two values, images or channels: the first contains the real part and the second the imaginary part of the inverse transformation.

Procedure: im-fcc image mask
Procedure: im-fncc image mask
Procedure: im-fcc-channel i-chan m-chan width height m-width m-height
Procedure: im-fncc-channel i-chan m-chan width height m-width m-height

Returns an image or a channel.

Computes and returns the Fast Cross Correlation or Fast Normalized Cross Correlation between image and a (usually smaller) mask22, using the Fast Fourier Transform23.


Footnotes

(21)

The FFT (Fast Fourier Transform) is simply a faster way to compute the Fourier transform. All FFT related procedures, and their inverse, are obtained by calling the FFTW library.

(22)

Also called a template, or a pattern.

(23)

Hence the names, FCC (Fast Cross Correlation) and FNCC (Fast Normalized Cross Correlation).


Next: Morphology, Previous: Process, Up: Image Processing   [Contents][Index]