Generate artistic bitmap and/or vector graphic images using Delaunay triangulation algorithm.
- Blur the original image using Gaussian blur algorithm.
- Create a grayscale image from the blurred image.
- Detect edges using sobel or laplacian algorithm.
- Apply a threshold on the image containing the edges of the original image. This serves as a noise reduction procedure.
- Get the remaining points and create a Delaunay mesh using the Bowyer-Watson algorithm.
- Reconstruct the image using the Delaunay mesh.
- Save the final image.
Java 17 is necessary to be able to build the project!
git clone https://github.com/Ernyoke/DelaunayImage.git
mvn clean package
- OpenCV
- JUnit5
- VectorGraphics2D
----Usage---
java -jar delaunay.jar <intput path> <output path> [args]
Mandatory (stationary) arguments: <input path> <output path>.
<input path>: path to the input image.
Extensions supported for input image: [all the extensions supported by opencv, see: https://docs.opencv.org/3.0-beta/modules/imgcodecs/doc/reading_and_writing_images.html]
<output path>: path to where the output image should be saved.
Extensions supported for bitmap output image: [all the extensions supported by opencv, see: https://docs.opencv.org/3.0-beta/modules/imgcodecs/doc/reading_and_writing_images.html]
Extensions supported for vector graphic output image: .svg, .eps (.pdf is currently no supported!)
Example of usage: java -jar delaunay.jar in.png out.png
-bk <nr>: blur kernel size, <nr> should be a positive odd integer. Default value: 35
-t <nr>: threshold value, <nr> should be a positive integer between 0 and 255. Default value: 200
-max <nr>: maximum number of points, <nr> should be a positive integer. Default value: 1000
-ea <alg>: edge detection algorithm, accepted values for <arg> are: sobel, laplacian. Default value: sobel
-sk <nr>: sobel kernel size, should be a value from the following set: [1, 3, 5, 7]. Default value: 3
-grayscale: setting this flag, the output image will be grayscale. Default value: false
-v: activate console logging. Default value: false
-wire: draw only wireframe for the triangles. Default value: false
-dbf: Delete border and all of the triangles which have a node on the border. Default value: false
-alg: Delaunay algorithm to be used. Accepted values: bw, delaunator. Default value: delaunator
Examples:
Example of usage: java -jar delaunay.jar in.png out.png -ea laplacian -sk 5 -max 2000 -t 200 -v
Example of usage: java -jar delaunay.jar in.png out.png -max 2000 -grayscale
- Laplacian algorithm is very sensitive to noise. Try to smooth out noise by using the right kernel size and sigma values.
- The number of the triangles is determined by the number of the -max points. This will also influence the average area size of the triangles. Smaller numbers of triangles will result in bigger ares and probably picture information loss.
- -v Verbose mode logs out every step of the procedure.
This project is under the MIT License. See the LICENSE file for the full license text.