Image edge detection and simple vectorization program using convolution filters
As assignment for our Object-oriented programming classes at the University of Strasbourg, we created a image contour detection program which uses convolution filters such as Sobel, Roberts or Prewitt. The program was extended to perform a naive vectorization of the input image. It can be then written down to a Scalable Vector Graphics (SVG) file.
The vectorization strategy used is very straightforward. Starting with a thresholded black and white image we iterate over and try to detect segments by inspecting neighbor pixels in three directions (right, diagonal right, down and diagonal left). Finally, the resulting set of detected segments allows to redraw the original image in a vectorized form.
As the program is written in Java, it can be used on any machine running a Java virtual machine.
Plus, the user interface is pretty straightforward to understand: import a source image, select the filter to apply, set desired threshold value, select output SVG file and perform vectorization.
At first, ensure there is Java Development Kit (JDK) installed on your computer providing the javac
and java
executables.
Then, from a Unix terminal or a Windows Command Prompt instance, navigate to the src
folder, compile the main program using javac Main.java
and run with java Main
.
Marek Felsoci, student at the University of Strasbourg.
Java Edge Detector and its source code are licensed under the terms of the GNU General Public License, version 2. See the LICENSE file for full license text.
The "Lena" image was acquired from i.stack.imgur.com/o1z7p.jpg.