JConvolve
A downloadable tool
This library can do all sorts of convolutions with more edge handling than the Standard Java Library and contains prebuilt Kernels. It requires the use of a subclass of Convolve, and a subclass of Kernel, or, optionally, use the Kernel class to use a custom matrix for the Kernel provided a 2D array of doubles.
Here is an example:
InputData input = new InputData();
input.setIn(ImageIO.read(new File("image.png")));
input.setOutLoc("out.png");
input.setKernel("Prewitt Horizontal");
input.setConvolve("Reflect");
ConvolveNoThread convolve = new ConvolveNoThread(input.getIn());
convolve.filter();
InputData's out variable will now be an image convolved by the Prewitt Horizontal kernel, with images reflected, from a file named image.png, to a file name out.png.
The subclasses of Convolve are specified by how the edge handling works, and include the following:
ConvolveNoOp - Returns the original image's pixel when handling edges.
ConvolveZero - Returns the color black when handling edges.
ConvolveWrap - Returns a pixel from the oppopsite edge when handling edges.
ConvolveReflect - Returns a pixel mirrored by the distance from the edge when handling edges.
ConvolveReflect is recommended for most cases.
The subclasses of Kernel are specified by what values are in its matrix, and include the following:
BlurKernel - All values in kernel are equal and are a fraction of the kernel's size.
This kernel takes an int n for matrix size.
GaussBlurKernel - Values in the kernel increase in size as you approach the center of the matrix.
This kernel takes an int n for matrix size as well as a double intensity for how strong the blur is.
EmbossKernel - Values in the kernel are positive around the top left corner, negative around the
bottom right corner, and have a line of zeroes from the bottom left corner to the top right corner. This kernel takes an int n for matrix size.
SharpenKernel - Values in the kernel are a negative fraction of the size of the kernel, except for the center value, which is one plus that negative fraction. This kernel takes an int n for matrix size.
The Prewitt, Sobel and Scharr Kernels can be specified horizontally or vertically, and always contain a 3x3 matrix, implying that they take no parameters in the constructor.
HorzMotionBlurKernel, VertMotionBlurKernel, and DiagMotionBlurKernel all blur the image along a straight line, Horz meaning horizontally, Vert meaning vertically, and Diag meaning any line specified by an angle in its constructor.
HorzMotionBlurKernel and VertMotionBlurKernel both take n, and DiagMotionBlurKernel also takes an angle in degrees.
RadMotionBlurKernel makes a radial blur, along the center of the image.
ZoomMotionBlurKernel makes a zoom blur from the center of the image.
This software is licensed by the Apache 2.0 license.
Status | Released |
Category | Tool |
Author | Light Anvil Software |
Tags | api, convolution, convolutions, image, image-processing, images, images-processing, java |
Download
Click download now to get access to the following files: