Next: Kernel Structure and Accessors, Up: Image Processing [Contents][Index]
The Guile-CV procedures and methods related to image data structure, creating, accessing and copying images.
im-make
im-make-channel
im-make-channels
im-copy
im-copy-channel
im-size_
im-width_
im-height_
im-n-channel_
im-channels_
im-channel
im-image?
im-gray?_
im-rgb?_
im-binary?
im-binary-channel?
im-=?
im-=-channel?
im-ref
im-fast-ref
im-set!
im-fast-set!
im-channel-offset
im-fast-channel-offset
im-channel-ref
im-fast-channel-ref
im-channel-set!
im-fast-channel-set!
im-collect
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 f32
is
the C type float
.
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 Red
, Green
and
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 (cv idata)
.
Note that the (cv)
module imports and re-exports, among may
others, the public interface of (ice-9 match)
.
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
image
.
Returns, respectively the width, the height, n-channel, channels or the nth channel for image.
Returns #t
if image is respectively a Guile-CV image, a
GRAY scale or an RGB image.
Returns #t
if i1 i2 i3 … or c1
c2 c3 … respectively are BINARY (Black and White)
images or channels respectively.
Note that when more then one image or channel is passed, they must all be of the same size.
Returns #t
if i1 i2 i3 … or c1
c2 c3 … respectively are of the same size, have the
same number of channels that all respectively contain the same values.
If the first argument is a number, it is used as the precision to
compare pixel values. The default precision value is 1.0e-4
.
Note that if you are certain your images or channels contain ’discrete’
float values, you may pass 0.0
as the precision to be used, i
which case values will be compared using =
(instead of
float=?
, which is faster.
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.
Returns nothing.
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.
Returns nothing.
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:
size
width
height
n-channel
channels
chan-0, gray, red
chan-1, green
chan-2, blue
chan-k (*)
(*): whith k being a valid channel indice, [0 (- n 1)].
Next: Kernel Structure and Accessors, Up: Image Processing [Contents][Index]