Other Guile-CV procedures and methods utilities.
Returns a new image or a new channel.
The valid position and alignment symbols are:
top center bottom
left center right
When used, the optional #:color keyword argument must come after
the mandatory alignment argument and precede img-1,
otherwise Guile will raise an exception. For RGB images, it is the
color used to padd images passed in argument that are inferior, in
width or height (depending on the position), to the biggest of them. For
GRAY images, the #:color is reduced to its corresponding gray
(/ (reduce + 0 color) 3)
im-compose-channels procedure, the list of
channels, widths and heights must be of equal length
and equally ordered, so the
nth element of widths and
heights are the
height of the
element of channels. The optional
#:value keyword argument
is used to padd channels that are inferior, in width or height
(depending on the position), to the biggest of them.
Displays the content of image or channel on port, applying proc to each pixel value.
... $5 = (3 2 3 (#f32(0.0 1.0 2.0 3.0 4.0 5.0) ... ...) (im-display $5 #:proc inexact->exact) -| Channel 1 0 1 2 3 4 5 Channel 2 6 7 8 9 10 11 Channel 3 12 13 14 15 16 17
Caution: unless you specify port, both this and im-display-channel procedures are ment to be used on very small and testing images, otherwise even on a small image, it might be ok in a terminal, but it will definitely will kill your emacs.
Returns two values: (1) an image; (2) a list (or a list of list) of significant values for image: one list if image is GRAY, a list of list of values per channel if image is RGB.
The returned image is composed of a header (title, #:subtitle),
either the GRAY or the RGB channel histogram(s) for image and a
footer, which is a table containg, for each channel, the following
followed by its
Here below, the call sequence and the histogram for the GRAY image sinter.png given along with Guile-CV documentation and examples:
scheme@(guile-user)> (im-load "sinter.png") $32 = (212 128 1 (#f32(25.0 39.0 50.0 52.0 51.0 45.0 # …))) scheme@(guile-user)> (im-histogram $32 #:subtitle "sinter.png") $34 = (282 271 1 (#f32(255.0 255.0 255.0 255.0 255.0 # …))) $35 = (27136 163.346 75.081 0 243 215 727)
Note that histogram images returned by
im-histogram have no
borders, the above histogram has been padded - using
1 1 1 1 #:color '(96 96 96)) - for better readability, otherwise the
title above and the table below would look as if they were not
Returns the string "#<Image: …>", where "…" is either filename or a filename constructed by im-show, see below.
These three methods will also effectively dislay the image if you are using Geiser, which analyzes Guile’s procedures and methods returned values (through the use of its pattern matcher), and when appropriate, triggers its image display mechanism.
Geiser has two variables that allow you to choose either to inline
images in its Emacs (Guile repl) buffer, or to
display them using externel viewer:
geiser-repl-inline-images-p. You may choose to add these
variables in your .emacs file, for example:
(setq geiser-image-viewer "eog") (setq geiser-repl-inline-images-p nil)
(setq geiser-repl-inline-images-p t) will only work if
you are using a graphics-aware Emacs, and otherwise, will fall on the
external viewer approach, if the variable
been defined. When using Geiser in a non graphics-aware Emac, or when
using the external viewer approach, images will appear as buttons: press
return on them to invoke (or raise) the external viewer (window
containing that image).
Except for the first
im-show method, Guile-CV has to save the
image first, and does it in the location defined by the
%image-cache variable. If you call
name, the image is saved as
%image-cache/name.png, otherwise under a generated name,
the result of
(symbol->string (gensym "im-show-")).
Note that if you do not specify name, a new external viewer window
is opened at each
im-show invocation, even for identical
image calls: this because in Guile-CV, on purpose, images are just
list, with no (unique) identifier, and there is no way for
im-show to know ... Further to this point, when you pass
name as an argument, you are not ‘identifying’ image,
which may actually differ, but rather just ask to reuse the filename and
hence the external viewer window associated with it.
Last note: many external viewers, such as Eog (the Gnome Eye Viewer),
will try to apply, per default, some sort of smoothing techniques,
zoom-out: where this is fine for
viewing ‘lazer’ pictures, you probably want to check and disable
these options when working with Guile-CV.
Specifies the location used by im-show to save images.
The default value is /tmp/<username>/guile-cv, but you may
set! it. If you’d like to reuse that location for future
guile-cv sessions, you may save it in guile-cv’s ‘per user’ config
file <userdir>/.config/guile-cv as an assoc pair, here is an
cat ~/.config/guile-cv.conf ((image-cache . "~/tmp"))
Note that if used, the ‘~’ is expanded at load time, so in geiser, it becomes:
scheme@(guile-user)> ,use (cv) scheme@(guile-user)> %image-cache -| $2 = "/home/david/tmp"
Specifies the format used by im-show to save images.
The default value is
"png", but you may
set! it. If you’d
like to reuse that format for future guile-cv sessions, you may save
it in guile-cv’s ‘per user’ config file
<userdir>/.config/guile-cv, as an assoc pair, here is an
cat ~/.config/guile-cv.conf ((image-cache-format . "jpg"))
The mode is the integer corresponding to the histogram entry that received the maximum of hits, and the value displayed in parens precisely is the number of hits.