The Guile-CV procedures and methods related to images data structure, creating, accessing and copying images.
A Guile-CV image is represented by a list containing the following elements:
(width height n-channel idata)
where idata is a list of n-channel elements, each element
being a vector of
(* width height) cells. More
precisely, each element is an
srfi-4 homogeneous numeric vector
of 32 bit floats, called
f32vector, knowing that
the C type
The external representation (ie. read syntax) for idata vectors is
#f32(…). As an example, a gray scale image of width 3 and
height 2, initialized to 0.0 is represented by the following expression:
(3 2 1 (#f32(0.0 0.0 0.0 0.0 0.0 0.0)))
The n-channel is an integer
>= 1, with no limit but the
memory size. This said, most Guile-CV procedures and methods expect
either GRAY scale (n-channel=1), or RGB (n-channel=3)
images. For the later, the channels are
Blue in that order.
Guile-CV provides usefull accessors for all these fields. However, very
often, you will need them all, in which case your best friend is
(ice-9 match), here is an example:
,use (cv) (define image (im-make 4 3 3)) (match image ((width height n-chan idata) (match idata ((r g b) ... your code here ...))))
You will find many examples of such a ‘pattern’ in Guile-CV’s
source code itself of course, along with some other ‘techniques’
that might be useful, so we invite you to read it, and if you do so:
feedback, design and code review is more then welcome! This section
describes what is in the module
Note that the
(cv) module imports and re-exports, among may
others, the public interface of
Returns a new image, list of channels or channel.
Each channel is an srfi-4 homogeneous vector of 32 bit floats (f32vector), of width by height initialized to value. The default value is 0.0
Returns a new fresh copy of image or channel.
Returns the list of
(width height n-channel)for
Returns, respectively the width, the height, n-channel, channels or the nth channel for image.
#t if image is respectively a Guile-CV image, a
BINARY (black and white), a GRAY scale or an RGB image.
im-image? is a relatively ‘expensive’ operation
and offered for debugging purposes, but it is not recommended to use
‘in production’; (b) because of the former,
im-rgb? do _not_ check if image is a valid Guile-CV image,
instead, they only check for n-channel=1 and n-channel=3.
#t if i1 i2 i3 … or images
are of the same size, have the same number of channels that all
respectively contain the same values.
If the first argument for
im-=? is a number, it is used as the
precision to compare pixel values: 1.0e-4 is the default precision
Returns the pixel value stored at position i and j of the image channel k. The default value for k is 0.
im-fast-ref does not check the validity of its arguments: use it at your own risk.
Sets the pixel value stored at position i and j of the image channel k to value. The default value for k is 0.
im-fast-set! does not check the validity of its arguments: use it at your own risk.
Returns the channel offset for the i and j indices, based on the width and height of the channel.
This procedure converts the matrix indices i and j to a vector offset for a channel of size width and height.
im-fast-channel-offset does not check the validity of its arguments: use it at your own risk.
Returns the pixel value stored at position i and j of the channel of size width and height.
im-fast-channel-ref does not check the validity of its arguments: use it at your own risk.
Sets the pixel at position i and j of channel of size width and height to value.
im-fast-channel-set! does not check the validity of its arguments: use it at your own risk.
Returns a list of what collected from i1 i2 i3 …
The valid what synbols are:
chan-0, gray, red
(*): whith k being a valid channel indice, [0 (- n 1)].