ShapeLogic is an open source toolkit for declarative programming, image processing and computer vision. Started August 2007.

Code hosted on From there you can download both source files and binary distributions.

Project home page is currently a work in progress.

Main ideas and motivation

ShapeLogic is a library for

While ShapeLogic's declarative programming system was initially developed for image processing and computer vision, it is widely applicable. It is currently difficult to combine declarative programming and image processing. ShapeLogic is intended as basic plumbing software that turns a logic engine into a simple plugin component to ease entry into vision and image analysis. ShapeLogic also fills gaps missing from current Java image processing libraries, and uses a commercially friendly license.

The current ShapeLogic working example demonstrates capital letter matching. Future, differing, examples to come.


  • Declarative lazy stream driven logic engine with lazy computations
  • Specialized for the domain of image processing and computer vision
  • The user can store rules in either a flat file or database, decreasing user reliance on Java programming
  • User rules are written with Java or the Java 6 Scripting interface JSR 223. Groovy, JRuby, JavaScript have been tested
  • Implementation of 2D geometry primitives, vectorization and segmentation
  • It is free (as in free speech and free beer)
  • Commercially friendly MIT open source software license, also called the X11 License
  • Annotations of point as different type of junctions, end points, hard or soft points
  • Annotations of lines as straight, curved, concave or inflection points
  • Programmed in Java
  • Can be used as a plugin for ImageJ, the leading Java open source project used in medical image processing


ShapeLogic uses the following libraries:

Development Status: Beta

  • ShapeLogic is in Beta, as of version 1.0.
  • There is a working example where ShapeLogic is used for matching capital letters.
  • The API is still under development.
  • Contains a framework for declarative and functional programming.
  • ShapeLogic currently consists of 25,000 lines of Java code including 380 unit tests.


2008/03/05 ShapeLogic v 1.0 released

  • Rule for image processing have been migrated, previously they were implemented as goal driven tasks with sub tasks. Version 1.0 uses lazy streams which is simpler and more powerful.
  • Letter match example now matches all polygons instead of just the first found.
  • When running ShapeLogic as ImageJ plugin, it is now easy for users to define rules for matching in external Java files.
  • New number matcher to demonstrate how to define rules for matching in external Java file, in 130 lines of code.
  • Enabled use of Java 6 Scripting for rule database, which gives the user access to the 25 scripting languages that are supported
  • ShapeLogic now has beta development status
  • Many unit tests added for Lazy Stream library
  • Fixed bugs in Lazy Stream library
  • Fixed bugs for the letter X

Documentation will soon be updated to reflect ShapeLogic 1.0.

Future plans for ShapeLogic

For more up to date information on ongoing development work look at these

ShapeLogic v 1.1 with particle counter example soon to be released

The main goal for 1.1 is to create an automatic color and gray scale particle counter example. This is the first use of ShapeLogic in medical image processing. There are currently particle counters available for ImageJ, however, ShapeLogic's particle counter will utilize declarative programming tools for a color image processing problem, making it function without manual user intervention.

The test images are taken from the sample images from ImageJ




Examples applications

  1. Letter matching example. Very rudimentary OCR.
  2. mathematical problems from Project Euler. This is a list of 178 mathematical problems that can be solved by computers. They vary in complexity from simple to hard. The goal is to test ShapeLogic's new declarative and functional constructs on real problems and make sure they are terse and intuitive.
  3. Next example will be an an automatic color and gray scale particle counter, first medical image processing example