An Implementation of Line Integral Convolution

by Bill Martin

Below, I have generated a set of point gravity sources randomly placed on a regular 32 x 32 grid. Vector data was generated at each cell by taking a weighted linear sum of the vectors between the center of the cell and each point source. The weight for each vector is the inverse of its magnitude squared. Thus the force exerted by each point source falls off as a function of the square of the distance, as can be observed on the left below (an iconic field representation via vtk). On the right, I show the white noise used to produce the LIC.

The LIC produces the 32 x 32 image below, magnified so as to be visible. The LIC brings out some interesting features -- note for example the dead region between the two point sources, where the forces nearly even out. Also, note how the lines of force curve when they pass between the two sources.

Below I have visualized a three source vector field on a 256x256 grid. I have included the image on the left below to illustrated some of the shortcomings of traditional iconic representations. The image was generated in vtk. Because of the large numbers of lines needed for this vector field, there are severe aliasing problems and loss of information. Fortunately, the three point sources are visible, giving us a context for the picture on the right. This LIC image clearly shows the lines of force present in the gravity field. Note the dead areas (equilibrium points) both toward the center of the image, and between the two point sources in the upper left. An important feature to notice is that color does not indicate field strength. The dark center of the upper right point source is just as strong at the bright center of the lower point source. The shading serves to point out where the streamlines are, but not their strengths.

We can indicate field strength at each cell by multiplying the texture obtained through LIC with an RGB value determined by the local field strength. Thus, we generate a color map which is indexed by field strength -- the images below were generated using a color map with three seed colors. Field strengths were normalized to have values between 0 and 1. On the left, green was assigned to zero, blue was assigned to 1, and red was assigned to .5. Field values in between produced a linear interpolation in the color map. Notice how much easier it is to locate the point sources, and the areas of high field strength. As a result of quadratic falloff in field strength, the majority of the field has been shaded green, with red and blue relegated to areas close to the source.

Below I provide a magnification of the area surrounding the two upper sources. Here the equilibrium points are more clearly visible -- particularly the zero force regions at the center of the point sources.

Cabral et al. (p. 269) introduced a scheme for processing images using LIC. First a gradient field is generated using a gradient approximation operator, such as Sobel. The gradient field points in the direction of maximum change, so by rotating the gradient field by 90 degrees, we can produce a field which is tangent to edges in the image. LIC can then be applied to the images, using the image itself as the texture map, and the tangent field as the vactor data. The result can be somewhat painterly. The images below were calculated using streamline lengths of 0, 10, 20 and 80. The effect of 20 and 80 is something like viewing the picture through a window covered with raindrops.

The effect was somewhat different when applied to a flower image. The result of using streamlines of length 0, 10, and 20 is shown below.

Some people have requested the source for my LIC implementation. It was never meant for general consumption. I'd like to claim it is research code, but it is worse than that. For what it is worth, here it is:

LIC Code

I have inclosed two sample input files. The usage is:

lic ps.vec.256.256.3 noise.256.256 256 256

Sources

1
Brian Cabral and Leith (Casey) Leedon. Imaging vector fields using line integral convolution. Proc. of SIGGRAPH '93 (Anaheim, California, August 1-6, 1993). In Computer Graphics 27, Annual Conference Series, 1993, ACM SIGGRAPH, pp. 263-272.
2
Detlev Stalling and Hans-Christian Hege. Fast and resolution independent line integral convolution. Proc. of SIGGRAPH '95 (Los Angeles, California, August 6-11, 1995). In Computer Graphics 29, Annual Conference Series, 1995, ACM SIGGRAPH, pp. 249-256.

Bill Martin (wmartin@cs.utah.edu)