Image Differentials

An ImageJ plugin that computes the gradient, Laplacian, and Hessian of a grayscale image

Philippe Thévenaz, Biomedical Imaging Group, Swiss Federal Institute of Technology Lausanne
OriginalGradient amplitude

Figure 1. Diatom (left) and its gradient amplitude (right).

I. Download

This distribution is dated Avril 7, 2014. It includes the complete set of source files, along with the precompiled classes.

II. Related work

This Java class is based on the following paper:
M. Unser, "Splines: A Perfect Fit for Signal and Image Processing," IEEE Signal Processing Magazine, vol. 16, no. 6, pp. 22-38, November 1999.
It is written as a plugin for ImageJ. Please read the ImageJ documentation to learn how to install the plugin.

III. Explanations

This plugin allows you to perform several differentiation operations on images, seen as continuous functions, even though they are stored as discrete pixels. The general principle is to construct the continuously defined function

ƒ(x, y) = k,l c[k,l] ⋅ φ(x-k, y-l).

Here, we shall concentrate on the specific case where the function

φ(x, y) = β3(x) ⋅ β3(y)

is a tensor-product (separable) cubic B-spline. Then, a typical example of spatial differentiation operation is

∂ƒ(x, y) ⁄ ∂y = k,l c[k,l] ⋅ β3(x-k) ⋅ ∂β3(y-l) ⁄ ∂y,

where we compute the exact vertical gradient of the continuously defined image.

IV. Operations

Gradient Magnitude, Gradient Direction, Laplacian, Largest Hessian, Smallest Hessian, Hessian Orientation

Figure 2. Possible operations.

V. Example

The following pair of images is typical of the kind of results you can obtain with the present program. The image on the left is the original image, while the image on the right shows its Laplacian.

Lena imageLaplacian of Lena

Figure 3. Left: 256×256 Lena input image. Right: Resulting Laplacian.

VI. Conditions of use

You'll be free to use this software for research purposes, but you must not transmit and distribute it without our consent. In addition, you undertake to include a citation or acknowledgment whenever you present or publish results that are based on it. EPFL makes no warranties of any kind on this software and shall in no event be liable for damages of any kind in connection with the use and exploitation of this technology.

VII. Programmer's note

The class Differentials_ contains the five following methods:

getCrossHessian(∂ƒ(x, y) ⁄ ∂x) ⋅ (∂ƒ(x, y) ⁄ ∂y)
getHorizontalGradient∂ƒ(x, y) ⁄ ∂x
getHorizontalHessian2ƒ(x, y) ⁄ ∂x2
getVerticalGradient∂ƒ(x, y) ⁄ ∂y
getVerticalHessian2ƒ(x, y) ⁄ ∂y2

These methods have two parameters each and perform the in-place processing of an object of type ImageProcessor, given as first parameter. The only image type that is currently implemented is ImagePlus.GRAY32.

The second parameter is a variable of type double that controls the compromise between speed and accuracy. Its value should be a small positive or null number. The best precision is achieved by setting tolerance = 0.0, at the expense of some (moderate) loss in efficiency. We have observed experimentally that the value that corresponds to the C constant FLT_EPSILON exhibits an excellent trade-off. In Java, this value can be written as Float.intBitsToFloat((int)0x33FFFFFF).