ShapeLogic Scala is a generic computer vision library with cross-platform GUI. You write your image processing algorithm once, and it will work for images based on byte, short, float and double.
It has standard image processing algorithms like: Invert, threshold, edge detection, segmentation, skeletonize, edge tracer, vectorizer, point and line annotation all written in generic idiomatic Scala.
"org.shapelogicscala" %% "shapelogic" % "0.9.0"
Versions available for Scala 2.11 and 2.12
clone git https://github.com/sami-badawi/shapelogic-scala.git
cd shapelogic-scala
sbt compile
sbt test
sbt stage
target/universal/stage/bin/shapelogic
or on Windows
target/universal/stage/bin/shapelogic.bat
ShapeLogic Scala has a simple JavaFX GUI, it can:
- Load and save images
- Undo and image info
- Invert
- Threshold, background and foreground selection
- Sobel edge detection
- Edge crawler with vectorizer and feature extraction for points and lines
- Segmentation
- Morphology: Skeletonize, outline, dilate, erode, open and close
- To gray scale, fill black and white
- Color channel chooser, channel swapper
- Version 0.9.0
- It is pretty simple to write image operations and add them to GUI
- In alpha, but getting more stable
- ShapeLogic Scala project site
- GitHub project
- Unit test using ScalaTest
- Google group
- Particle analyzer and line finder as start of OCR system
- Output annotated points, lines and polygons in json format
- Work well with Java image processing libraries like: ImageJ, BoofCV and OpenCV Java
ShapeLogic Scala goal is be a framework for object recognition using a hybrid approach to A.I. combining machine learning and symbolic A.I. Using some of the following techniques:
- Machine learning
- Convolutional neural network
- Logistic regression, Naive Bayes or random forest
- Baysian network / graphical model
- Symbolic artificial intelligence
- Lisp like tree search / lazy stream
- Logic programming
- RDF or knowledge graph
- Database
First example will be OCR, optical character recognition for a page of text. It is a solved but nontrivial problem.
The success of Convolutional Neural Network is indisputable. ShapeLogic intend to use CNN for lower level pattern matching not for end to end solutions. Either using TensorFlow's Java interface, Deeplearning4j or hand programmed pattern matches.
ShapeLogic Scala has a unified generic image class BufferImage that is mainly a buffer.
If you want to program your own image operations here are 5 base image operations you can start from:
There are a lot of challenges with creating a generic image class like BufferImage:
- Bytes are signed in Scala and Java but unsigned for images
- Primitive numeric types are not a subclass of anything
- Byte needs to be promoted to integers, while float do not, normal generic classes will not do this
- Some sort of dependent types are needed which can be accomplished using type level programming
- Type classes can be used to define number, but they do not play well type level programming
- The image class need to be specialized to avoid boxing of primitive operation
ShapeLogic Java was started in 2007 as a Java image processing library and library for functional programming techniques in Java. Functional programming now has better implementations in Java 8 and Scala. ShapeLogic Scala was started in 2016 and ports parts of ShapeLogic Java.
The goal is to keep library dependencies for ShapeLogic low. Currently the images loaders are using javax.imageio and JavaFX. They are only part of Oracle JDK not on OpenJDK.
- Stardard Git and SBT Scala project
- Dependencies on
- Spire for generic math
- javax.imageio for images IO
- JavaFX for GUI
- Breeze for linear algebra and machine learning
Threshold:
sbt 'run-main org.shapelogic.sc.script.Threshold -i "image/rgbbmwpng.png" -t 10 -o "image/out.png"'
or
target/universal/stage/bin/shapelogic -main "org.shapelogic.sc.script.Threshold" -- -i image/440px-Lenna.png
- Repo owner: Sami Badawi / @Sami_Badawi