- Color spaces
- Creating images
- Basic image information
- Logical and morphological operations
- PNM movies
- Image operations
- Image pairs
- Colour Threshold
- Histogram Equalization
- Adaptive Thresholding
- Rendering Line Segments
- Points and bounding boxes
- Connected Components
- Distance Transform
This page is maintained in the package's github repository.
This is a Chicken Scheme egg with various image processing utilities.
Note that a few of these functions call ImageMagick.
These are exposed in case we want to switch to 16-bit grayscale or colors.
- rgb->hsv rgbprocedure
- hsv->rgb hsvprocedure
- rgb->cd rgbprocedure
- rgb->cmyk rgbprocedure
- rgb->uv-hsv cprocedure
Various color space conversions. Colors are vectors of values.
- rgb->xyz cprocedure
- xyz->rgb cprocedure
- xyz->l*ab cprocedure
- l*ab->xyz cprocedure
- rgb->l*ab cprocedure
- l*ab->rgb cprocedure
Convert to l*ab. Colors are vectors of values. This is space in which Euclidean distance is similar to human perceputal distance. These implement a 2 degree observer and the D65 illuminant.
- rgb->html cprocedure
Not really a color space conversion, covert an rgb color to an HTML color #rrggbb.
- define-structure pbm raw? bitmaprecord
- define-structure pgm raw? maxval greyrecord
- define-structure ppm raw? maxval red green bluerecord
- pnm? mprocedure
Three image formats are supported. PBMs are binary images, PGMs are greyscale and PPMs are tri-plane (nominally RGB) images. All planes are stored as scheme matrices. Together all of these formats are called PNM. This is a standard format that many tools (such browser and ImageMagick) can read and write. PNMs can be serialized as either raw packed binaries or ascii text files. Note that we are unable to read or write raw PBMs.
- image-ref i pprocedure
Index into an PNM image or into a matrix. This is like indexing into a matrix except that the arguments are reversed. A matrix-ref takes the row and then the column, image-ref takes a point which is an (x,y) coordinate.
- pbm-ascii pbmprocedure
Ensure that the PBM image is in ascii. We are unable to read or write raw PBMs.
- pnm-copy pnmprocedure
The resulting image will not share any data with the original.
- read-pnm pathnameprocedure
Read a PNM. We determine the kind of image (PBM, PGM, PPM see above) from the file header.
- write-pnm pnm pathnameprocedure
Write a PNM. If don't provide an extension an appropriate one will be appended to your pathname.
- pbm-constant width height bitprocedure
- pgm-constant width height greyprocedure
- ppm-constant width height red green blueprocedure
Create constant images.
- pbm-left-vertical-stripe width height leftprocedure
Create a black vertical stripe on a white image.
- crop-image pnm x y width heightprocedure
Crop an image and return a new image of the given size.
- pbm->pgm pbmprocedure
- pgm->ppm pgmprocedure
- pbm->ppm pbmprocedure
- ppm->pgm ppmprocedure
Various image conversions.
- pgm->pbm pgm thresholdprocedure
- ppm->pbm ppm thresholdprocedure
Convert a color or greyscale image to a binary image with the provided threshold.
- ppm-hue ppmprocedure
- ppm-saturation ppmprocedure
- ppm-value ppmprocedure
Creates a greyscale image representing one of the HSV channels from a color image.
- ppm-mean image colour-transformprocedure
- ppm-covariance image colour-transformprocedure
- pgm-mean imageprocedure
- pgm-variance imageprocedure
Compute the mean or covariance of an image. These take an optional colour transform.
- pbm-and pbm1 pbm2procedure
- pbm-or pbm1 pbm2procedure
- pbm-not pbmprocedure
- pbm-xor pbm1 pbm2procedure
Basic logical operations on binary images.
- pgm-absolute-difference pgm1 pgm2procedure
Compute the difference between two greyscale images.
- empty-pnm? pnmprocedure
Is this image empty?
- pbm-flood pbm pointprocedure
Floor fill a binary image.
- pnm-movie-frame-pathname pathname iprocedure
- pnm-movie-length pathnameprocedure
- read-pnm-movie pathnameprocedure
- write-pnm-movie pnm-movie pathnameprocedure
A PNM movie is a sequence of PNMs on disk.
- overlay-pbm-on-pnm pbm pnmprocedure
The white pixels in the pbm become white in the resulting image.
- pnm-black-window pnm upper-left lower-rightprocedure
- pnm-white-window pnm upper-left lower-rightprocedure
Draw white or black windows on an image.
- pbm-ppm-and pbm ppmprocedure
- pgm-and-pbm pgm pbmprocedure
Black pixels in the PBM become black pixels in the result.
- pnm-shift pnm deltaprocedure
Shift an image down and rightward by the give number of pixels.
- pgm-smooth pgm sigmaprocedure
Smooth a greyscale image with the given variance.
- pbm-proximity-clusterer pbm thresholdprocedure
Cluster white pixels in the binary image with the given distance threshold.
- pnm-rotate pnmprocedure
- pnm-flip pnmprocedure
Rotate (transpose) an image or flip (mirror) an image.
- ppm-burn base mask colourprocedure
Burn the ppm with the given mask and color.
- normal-flow-magnitude pgm1 pgm2 epsilon sigma sensitivityprocedure
- threshold-normal-flow-magnitude pgm1 pgm2 epsilon sigma thresholdprocedure
Compute normalized flow between two pairs of greyscale images.
- flatten-ppm ppm colour-transformprocedure
Returns a single matrix from a tri-plane PPM. This maps colour-transform over the image.
- binary-threshold pgm thresholdprocedure
Threshold a greyscale image.
- find-threshold-otsu pgmprocedure
- binary-threshold-optimal pgmprocedure
Otsu's Method to find an optional threshold and apply it.
- find-threshold-means pgmprocedure
- binary-threshold-means pgmprocedure
Method of Successive Means to find an optimal threshold and apply it.
- sample-image ppm colour-tx window-centre window-sizeprocedure
Map colour-tx over an region of a color image.
- binary-threshold-colour ppm colour-tx point thresholdprocedure
Binary threshold a colour image by sampling a region around the given point and thresholding all values that are within the given distance threshold of the mean color of that region.
- colour-threshold ppm colour-tx mu isigma thresholdprocedure
Binary threshold a colour image with the given mean and variance. The mahalanobis-distance between each pixel and the given mean and variance will be computed and compared to the threshold.
- histogram-equalise pgmprocedure
Equalize a greyscale image.
- make-integral-matrix matrixprocedure
Given a matrix compute an integral matrix which can provide the mean value of a rectangular region in O(1).
- compute-integral-matrix-mu integral-matrix x y wprocedure
- compute-integral-matrix-sigma squared-integral-matrix mu x y wprocedure
This computes the mean and variance of a square of size w in the given integral matrix.
- compute-adaptive-threshold integral-matrix squared-integral-matrix x y wprocedure
Compute an adaptive threshold on the given integral matrix.
- adaptive-threshold pgm winsizeprocedure
Compute an adaptive threshold for a greyscale image with a given window size.
- slide-window m f sizeprocedure
Map f over a matrix passing it square submatrices of the given size. At the edges f is passed #f.
- count-pixels aprocedure
Count number of true values in a matrix.
- ppm->label-closest ppm mu1 sigma1 mu2 sigma2 #!optional colour-transformprocedure
Create a binary image from a color image where points are either white or black depending on which is closer to the given means and variances.
- find-histogram pixmap maxvalprocedure
- histogram-mean histogram iprocedure
- histogram-variance histogram mu iprocedure
- normalised-histogram histogram valprocedure
- weighted-histogram histogramprocedure
- cumulative-histogram histogramprocedure
- find-between-class-variances omegas mus mu-totalprocedure
Compute histograms from a matrix.
- midpoint lprocedure
Compute the midpoint of a line segment.
- orientation vprocedure
Compute the orientation of a vector.
- line-segment-orientation lprocedure
Compute the orientation of a line segment.
- line-segment->points lprocedure
- line-segments->points lsprocedure
- points->line-segments psprocedure
Convert between points and line semgents.
- points->pbm-of-size points height widthprocedure
Take the list of points and create a binay image of the given size where those points are white.
- points-bounding-box pointsprocedure
Computing a bounding box for a set of points.
- bounding-box-size bbprocedure
Compute the size of a bounding box
- points->points-bounding-box points bbprocedure
Recompute the coordinates of the given points relative to the top-left corner of the bounding box.
- points->bounding-box-points pointsprocedure
Convert points to a list of points on the bounding box of those points.
- normalize-to-bounding-box psprocedure
- normalize-to-other-bounding-box points psprocedure
- points->target-bounding-box points target-bbprocedure
- points->other-target-bounding-box points ps target-bbprocedure
Normalize the cooredinates of these points to their bounding box. Or to the bounding box of the given points.
- bounding-box-bloat bb pprocedure
Bloat a bounding box.
- bounding-box-crop bb imageprocedure
Crop a bounding box out of an image.
- pbm->points pbmprocedure
- points->pbm points height widthprocedure
Convert a binary image to a set of points or vice versa.
- quantize-coordinate xprocedure
- quantize-point pprocedure
- quantize-points psprocedure
- quantize-line-segment lprocedure
- quantize-line-segments lsprocedure
Quantize coordinates, points or line segments.
- define-structure ellipse x0 y0 t0 a bprocedure
- ellipse-center ellipseprocedure
- ellipse-area ellipseprocedure
- ellipse-eccentricity ellipseprocedure
Define and compute basic properties of ellipses.
- radial-distance theta phiprocedure
The radial distance between two angles.
- point-on-ellipse? p ellipse toleranceprocedure
Compute if a point is on an ellipse.
- line-segment->ellipse lprocedure
Place an ellipse around a line segment
- ellipse->points e #!optional (n 360)procedure
Sample n points on an ellipse.
- resize-image w h iprocedure
Resize an image. This is quite slow as it writes the image out and calls imagemagick to resize it.
- subsample-pbm pbmprocedure
Subsample a pbm by a factor of 2.
- scale-ppm ppm scaleprocedure
Scale a pbm by a factor of 2 or 4.
- connected-component-filter pbm delta thresholdprocedure
Compute connected components of a binary image with distance thershold delta and size threshold threshold.x
- define-private-structure vertex pixels vertex edgesrecord
- define-private-structure edge u vrecord
- define-private-structure graph vertices edgesrecord
These are defined private for now as they need to be renamed.
- pbm->graph pbm deltaprocedure
- labeling->graph labeling deltaprocedure
Convert a binary image to a graph where pixels within delta of each other are connected.
- dereference-vertex uprocedure
- connected-components gprocedure
Compute the connect components of a graph.
- vertices->pbm vertices height widthprocedure
- graph->pbm g height widthprocedure
Convert a graph or list of vertices to a pbm.
- pbm->chains pbmprocedure
Convert a binary image to a list of chains, pixels that are connected to each other.
- chains->pbm chains height widthprocedure
Convert a list of chains to a pbm.
- chain-filter pbm thresholdprocedure
Filters chains below a certain length.
- conjure pbms delta span threshold1 threshold2procedure
Fill in missing values in pairs of frames.
- distance-transform pbmprocedure
- closest-transform-ref closest-transform pprocedure
Compute the Manhattan distance transform for a binary image and reference into that distance transform.
- euclidean-1d-dt vprocedure
- euclidean-2d-dt mprocedure
- euclidean-1d-dt-vals vprocedure
- euclidean-2d-dt-vals mprocedure
Compute a generalized squared-euclidean distance transform on the given vector or matrix. The -vals version also returns a map of the closest points.
- define-structure pnm-buffer buffer width height pixfmt storage typerecord
A mechanism to store raw image pointers.
- pnm->pixfmt p p4?procedure
- pixfmt->stride pixfmtprocedure
- image-type->pixfmt t p4?procedure
- image-type->storage-size t p4?procedure
- pnm->image-type pprocedure
- pnm->storage pprocedure
- pixfmt->red pixfmtprocedure
- pixfmt->green pixfmtprocedure
- pixfmt->blue pixfmtprocedure
- pnm-buffer-size p p4?procedure
- pnm->pnm-buffer! p #!rest p4?procedure
- pnm-fill-buffer! p b pixfmtprocedure
- free-pnm-buffer! pprocedure
Misc raw image buffer operations.
- imlib-image->pnm-buffer! imageprocedure
- imlib-image->ppm imageprocedure
- ppm->imlib-image ppmprocedure
Convert between PPMs and Imlib images. PGMs and PBMs must first be converted to PPMs because Imlib only handles RGB images.
- pnm-buffer->pnm bprocedure
- pnm-buffer->pbm pprocedure
- pnm-buffer->pgm pprocedure
- pnm-buffer->ppm pprocedure
Convert a raw image buffer to a scheme image.
- image->pnm-buffer! imageprocedure
Convert any image to a raw image buffer.
- ppm-absolute-difference ppm1 ppm2procedure
Compute the absolute difference between two color images.
- set-ppm-pixel! ppm x y valueprocedure
Set a pixel in a color image to a given value (a 3-vector).
- pnm-pixel? i x yprocedure
Is this a valid position in the given image?
- map-ppm-values ppm fprocedure
Map f on each component of each pixel in the image.
- pbm-stack-vertical pbm1 pbm2procedure
- pbm-stack-horizontal pbm1 pbm2procedure
- ppm-stack-vertical ppm1 ppm2procedure
- ppm-stack-horizontal ppm1 ppm2procedure
- degrees->radians angleprocedure
- radians->degrees angleprocedure
- normalize-rotation rotationprocedure
- rotation+ x yprocedure
- rotation- x yprocedure
- angle-separation x yprocedure
- mean-angle anglesprocedure
Misc operation on angles.
- rotation-matrix-2d thetaprocedure
Produce the 2D rotation matrix for the given angle.
- show iprocedure
Display an image. This invokes feh.
Written by the [[Center for the Computational Study of Cognition, Control, and Perception|http://upplysingaoflun.ecn.purdue.edu/~qobi/cccp/]].
Maintainer: Andrei Barbu, firstname.lastname@example.org
Copyright 1993-1995 University of Toronto. All rights reserved. Copyright 1996 Technion. All rights reserved. Copyright 1996 and 1997 University of Vermont. All rights reserved. Copyright 1997-2001 NEC Research Institute, Inc. All rights reserved. Copyright 2002-2013 Purdue University. All rights reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses.