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 goal 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 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: Alpha

  • ShapeLogic is in Alpha, as of version 0.7.
  • There is a working example where ShapeLogic is used for matching capital letters.
  • The API is still under development.
  • The framework for declarative and functional programming is being developed.
  • ShapeLogic currently consists of 19,000 lines of Java code including 250 unit tests.


2008/01/23 ShapeLogic v 0.9 released

This is the first release where ShapeLogic is moving beyond current parameters as a plugin library for ImageJ, currently only used in a letter recognition example. The improved system will be for declarative programming where the user can define rules in either a database or flat file. The focus will still be on image processing and computer vision, but the system will be more broadly applicable. There has been no new work on image processing or letter recognition in this release. ShapeLogic v 1.0 will combine these new changes with the current rule base code for image processing.

  • Introduce new functional, declarative and query constructs
  • Implement lazy streams like Haskell, Scala or Scheme
  • These functional constructs are very lightweight and you only need one 200KB jar file to use it in other applications
  • Test streams by solving the first 10 mathematical problems from Project Euler
  • Enabled Java 6 Scripting for evaluating expressions
  • Tested with Groovy, JRuby, JavaScript, but should work with other supported Scripting languages, currently that are 25 of these. This makes it possible for users to add rule, formulas and queries in real time using text format. They can interact with a running Java application, which can be useful in science, finance or web application.

Future plans for ShapeLogic

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

ShapeLogic v 1.0 soon to be released

When the declarative and functional constructs have been tested in pure form, move the current image processing and vision code to use these.

  • Integrate new functional and declarative construct with current goal driven logic used for image processing
  • Better integration of external user defined rule databases
  • Make the annotation of shapes more loosely coupled
  • Use Or tasks
  • Finish Javadoc for ShapeLogic

Next examples

The next example applications for ShapeLogic will be

  1. Solve some mathematical problems from Project Euler. It 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.
  2. Medical image processing