cyrusharmon.org

Cyrus Harmon's new completely useless blog

 

opticl: an image processing library for common lisp

posted by cyrus in Lisp

I'd like to officially announce the availability (and perhaps more importantly, the quicklisp-installability) of opticl, a new image processing library for Common Lisp with a BSD-style license.

Opticl can be found on the opticl github page. To install opticl from quicklisp, do:

(ql:quickload 'opticl) 

from a suitable lisp with quicklisp installed. Opticl has been mostly developed on SBCL, but should work on any Common Lisp, and has seen some limited testing on CCL and ABCL. Patches to more fully support other lisps would be most welcome, should they be needed.

Opticl picks up many of the ideas and concepts from my earlier ch-image image processing library and Matthieu Villenueve's IMAGO library, but offers some advantages over both packages, such as the direct use of common lisp arrays for images and the efficient access to both getting and setting pixel values using mulitple-values, a setf-exapnder and, where available, CLtL2-style variable information to provide hints to the compiler to generate efficient code using standard lisp type declaration expressions.

Some of the core features of opticl are:

  • representation of various types of 2-d images in common lisp arrays and routines for making the appropriate arrays
  • routines for efficiently performing affine transformations of images providing for operations such as resizing, scaling, rotating and skewing images
  • support for discrete convolution with arbitrary kernels, with built-in kernels for blurring and sharpening images
  • support for morphological operations with arbitrary kernels, with built-in kernels for dilating and eroding images
  • simple drawing primitives
  • performing gamma computations on images
  • I/O routines to read and write from various file formats; currently supported filetypes are JPEG, PNG, TIFF, PBM, PGM, PPM and GIF.
  • routines for converting between various image types
  • k-means clustering of pixels in images

More details about opticl can be found in the README, and in the opticl-test and opticl-examples packages. Note that these packages have been broken out into their own repositories in order to keep the size of a core opticl installation to a minimum. Currently opticl checks in around 3,500 lines of lisp code and the code compiles to approximately 900k of fasl files on SBCL/x86-64.

opticl: an image processing library for common lisp