2. Computer vision with computer algebra systems

27
Computer Vision and Mathematica Bart M. ter Haar Romeny, PhD Department of Biomedical Engineering Eindhoven University of Technology The Netherlands Email: [email protected] To appear in: Computing and Visualization in Science, Springer Verlag, 2002. Abstract Computer vision algorithms are strongly based on advanced mathematical methods. Tools to efficiently develop new methods are increasingly based on computer algebra systems, such as Matlab, Maple and Mathematica. For rapid prototyping both symbolic as numerical capability is required. However, the application to large datasets such as images has always been frustated by the expensive use of memory or long computing times. Today such programs have improved substantially in numerical data handling, making them an ideal tool for rapid prototyping in computer vision. This paper gives a short variety of examples of the use of Mathematica in computer vision research. 1. Introduction Modern computer vision research heavily relies on advanced mathematical methods, like differential geometry and invariant theory, linear algebra, topology, variational techniques, group theory, mathematical statistics etc. The increased capability of computer algebra systems like Matlab, Maple, and Mathematica have given the field a boost. However, most of the final applications in practice are still written in C++, as this still gives the best speed for large datasets, such as images. Many efforts have been undertaken to set up repositories of image processing routines, leading to quite a few commercial packages and web-based collaborations between labs. A spectrum from classical routines as filters, mathematical morphology operations, histogram based methods, etc. to the more advanced mathematical methods is developed. Most such packages start building from scratch, and need heavy manpower investments in I/O, data format handling, GUI development, and a long list of specific routines for the different tasks.

Transcript of 2. Computer vision with computer algebra systems

Page 1: 2. Computer vision with computer algebra systems

Computer Vision and Mathematica

Bart M. ter Haar Romeny, PhD

Department of Biomedical EngineeringEindhoven University of TechnologyThe Netherlands

Email: [email protected]

To appear in: Computing and Visualization in Science, Springer Verlag, 2002.

Abstract

Computer vision algorithms are strongly based on advanced mathematical methods. Tools to efficientlydevelop new methods are increasingly based on computer algebra systems, such as Matlab, Maple andMathematica. For rapid prototyping both symbolic as numerical capability is required. However, theapplication to large datasets such as images has always been frustated by the expensive use of memoryor long computing times. Today such programs have improved substantially in numerical data handling,making them an ideal tool for rapid prototyping in computer vision. This paper gives a short variety ofexamples of the use of Mathematica in computer vision research.

1. Introduction

Modern computer vision research heavily relies on advanced mathematical methods, like differentialgeometry and invariant theory, linear algebra, topology, variational techniques, group theory,mathematical statistics etc. The increased capability of computer algebra systems like Matlab, Maple,and Mathematica have given the field a boost. However, most of the final applications in practice arestill written in C++, as this still gives the best speed for large datasets, such as images.

Many efforts have been undertaken to set up repositories of image processing routines, leading to quitea few commercial packages and web-based collaborations between labs. A spectrum from classicalroutines as filters, mathematical morphology operations, histogram based methods, etc. to the moreadvanced mathematical methods is developed. Most such packages start building from scratch, and needheavy manpower investments in I/O, data format handling, GUI development, and a long list of specificroutines for the different tasks.

Page 2: 2. Computer vision with computer algebra systems

However, too often a carefully constructed library for dedicated image processing routines developed ina lab turns out to be difficult to maintain, as the manpower investments are seen to be prohibitive in thelong run. Additionally, it has often been a difficult problem to reuse libraries written in these mediumlevel languages by new students and collegues, as documentation is often a stepchild, the code is oftenlong and relies on local libraries, and the authors (e.g. graduate students) often leave the lab when thecode needs upgrading to joint library level.

Actually, the role of pixels is not important at all. It is all about the mathematical strategy that has to beapplied to the image, which is a sampling of some continous reality. It is here that the role of moderncomputer algebra packages gains ground. Traditionally, packages as Reduce, Axiom, Maple andMathematica were only used for the symbolic, analytical calculations, while Matlab today seems theprogram of choice for fast numerical implementation. It was of no use to try to let Mathematica work onthe large datasets of (multidimensional) images. The internal representation of infinite precisionnumbers, the in principle being D-dimensional of the routines and the interpreter structure made a hugememory consumption necessary.

The ideal situation for rapid prototyping in computer vision is to combine the analytical power with thenumerical power in a single, well balanced and tuned package. Recently Mathematica has improved thenumerical efficiency in such a way, that it now feasible to apply complex routines to regular size imageswith such speed that research is not hampered by long experimentation cycles. In this paper we willshow a number of relevant examples from mathematical computer vision research, where theimplementation is greatly assisted with both the symbolic and the numerical implementation in a singlepackage. A key aspect is the powerful pattern matching technique, which enables a stepwise approach:the formulas are derived analytically, no matter how complicated they are; the resulting analyticalresults (e.g. a polynomial with many high order derivatives, a nonlinear PDE, SVD results, Eigenvalues,etc) can then be applied to images by a Replace construction.

2. Computer vision with computer algebra systems.

We can now do mathematical prototyping with computer vision principles/techniques on images. Theintegration of both symbolic and fast numerical capabilities, and the powerful pattern matchingtechniques make up for a new and efficient approach to apply and teach computer vision, more suitablefor human mathematical reasoning. It is now easy to do rapid prototyping. If one can express theproblem in a concise English sentence, one has already half of the code. This is mathematical

programming, in contrast with the traditional object oriented or structured programming. The examplesin the rest of the paper come with the complete code of every method discussed, ready for testing. It iseasy to modify the applications and apply them to any of the reader's images.

All programs become compact which greatly benefits readability. In this paper no example exceeds 20lines of code. There are no for, while or do loops. Most commands have the attribute Listable,

i.e. operate on any member of the operand list. The language contains hardly abbreviations, and is sointuitive that learning the language may be mastered quickly.

2

Page 3: 2. Computer vision with computer algebra systems

Modern computer algebra systems contain hundreds to thousands of higly optimized mathematicalroutines, which relieves the computer vision programmer from searching for routines in NumericalRecipes, IMSL etc. and have extensive graphical capabilities for 1D to 4D (animations). It iscomfortable for research institutes if a common complex source code is kept updated and based on thelatest mathematical insights by a professional organization/company. The core business of a researcherin computer vision is computer vision, not e.g. the rewrite of or search for a Fourier transform to 5dimensions with a prime number optimization scheme for odd-sized images.

The breakthrough point for image analysis is that present systems are substantially faster then a fewyears ago. The run-time of most experiments described in this paper is within seconds on a typical800MHz 128 MB Pentium III system under Windows.

Of course, there is the 'realtime environment', where operations need to be done in milliseconds. Thisrequires mostly an industrial environment, as these are requirements of products, and/or should beimplemented in dedicated hardware (DSP, advanced graphics chips). If for a specialized routine older orelsewhere developed C or C++ code exists, it is easy to embed this code into most computer algebrasystems (see the resp. documentation). The strategy promoted and examplified in this paper relates tothe prototyping research with fast iteration turn-around time for development of complex computervision routines.

3. Applications

The main part of the paper shows a variety of applications where the symbolic and numerical strength isexploited simultaneously. We start the applications with some initializations (code: see appendix) to setpaths and convenient options for several functions.

A major result from scale-space theory (multiscale image analysis) is that the Gaussian kernel and all ofits partial derivatives are a unique set of operators for a front-end visual system. They satisfy theconstraints for unbiased observation: no preference for location, scale and orientation, as well aslinearity. They form a one-parameter family G x, y;

of kernels, where the scale

is the freeparameter. Here are the plots of some members of the Gaussian derivative family:

3

Page 4: 2. Computer vision with computer algebra systems

g :1

2 2Exp

x2 y2

2 2; 1; Block $DisplayFunction Identity ,

graphs Plot3D Evaluate # , x, 3.5, 3.5 , y, 3.5, 3.5 &

g, xg, x y g, x,x g y,y g ;

Show GraphicsArray graphs , ImageSize 550 ;

Figure 2. Gaussian derivative plots of g x, y , x g x, y g x,yx , x y g x, y

and x,x g x, y y,y g x, y .

An observation of a continuous luminance distribution L x, y

in the outside world with an aperturefunction G x, y;

is mathematically described by a convolution: L x, y G x, y; . A basictheorem of scale-space theory states that derivatives of (observed, i.e. sampled) images are by necessityto be extracted by a convolution of the derivative of the measurement kernel, i.e. convolution withderivatives of the Gaussian kernel (due to the linearity of the operations of convolution anddifferentiation):

x L x, y G x, y; L x, y x G x, y;

This implies that differentiation is done by integration, and leads to regularized derivatives on discretedata, such as images. The spatial convolution with the Gaussian derivative is constructed with the speed-optimized function ListConvolve:

gD im_List, nx_, ny_, _ :

Module x, y, kx, ky, mid, tmp ,

gauss x,1

2 2Exp

x2

2 2;

kx N Table Evaluate D gauss x, , x, nx , x, 6 , 6 ;

ky If nx ny, kx, N Table Evaluate D gauss y, , y, ny ,

y, 6 , 6 ; mid Ceiling Length #1 2 & ;

tmp Transpose ListConvolve kx , im, 1, mid kx , 1, mid kx ;

Transpose ListConvolve ky , tmp, 1, mid ky , 1, mid ky ;

The kernel is approximated over the interval 6 , 6 , and due to the separability of the Gaussianfunction the 1D convolution is applied twice, first on the rows, then on the columns. Here is a scale-space of images in stacked view:

4

Page 5: 2. Computer vision with computer algebra systems

im Import "mr64.gif" 1, 1 ;

Block $DisplayFunction Identity, xres, yres, max ,

yres, xres Dimensions im ; max Max im ;

gr Graphics3D ListPlot3D Table 0, yres , xres ,

Map GrayLevel, im max, 2 , Mesh False, Boxed False ;

gb Table blur gD im, 0, 0, i ; Graphics3D

ListPlot3D Table i 10, yres , xres , Map GrayLevel, blur max, 2 ,

Mesh False, Boxed False , i, 1, 6 ;

Show gr, gb , BoxRatios 1, 1, 1 , ViewPoint 1.190, 3.209, 1.234 ,

DisplayFunction $DisplayFunction, Boxed True ;

Figure 3. A scale-space of a 2D MRI sagital slice, dimensions 642 , for a range of scales =1,2,3,4,5,and6 pixels.

To find in a checkerboard the crossings where 4 edges meet we need to design a specific detector. Aprimary requirement for feature detction in images is that detectors should be invariant under orthogonaltransformations (rotations, translations, mirroring). In other words, the choice of coordinate systemshould not matter. The differential invariant feature detctor for 4-edge crossings is fourth order detector.As an example of the strength of the combined symbolic and numerical capability of Mathematica wederive the detector from algebraic invariants theory. Even at orders of differentiation as high as 4, theinvariant features can be constructed in practice and calculated for discrete images through the(biologically inspired) scaled Gaussian derivative operators. The method is developed by Salden et al.[Salden1999a].

Local image structure is described through the local Taylor expansion around the point. In order tostudy the pure fourth order structure, we consider the fourth order polynomial terms from the Taylorexpansion (and do not include other order terms):

5

Page 6: 2. Computer vision with computer algebra systems

pol4 Lxxxx x4 4 Lxxxy x3 y 6 Lxxyy x2 y2 4 Lxyyy x y3 Lyyyy y4;

Here Lxxxx denotes 4Lx4 . The main theorem of algebra states that a polynomial is fully described by its

roots: e.g. ax2 bx c x x1 x x2 . It was shown more than a century ago by Hilbert[Hilbert1890] that the 'coincidencesness' of the roots, or how well all roots coincide, is a particularinvariant condition. From algebraic theory it is known that this 'coincidenceness' is given by thediscriminant, defined below (see also [Salden1999a]):

Discriminant p_, x_ :

With m Exponent p, x , Cancel1

12 m m 1 Resultant p, x p, x

Coefficient p, x, m

The resultant of two polynomials a and b , both with leading coefficient one, is the product of all thedifferences ai b j between roots of the polynomials. The resultant is always a number or a polynomial.The discriminant of a polynomial is the product of the squares of all the differences of the roots taken inpairs. We can express our function in two variables x, y

as a function in a single variable xy by the

substitution y 1. Some examples:

Discriminant Lxx x2 2 Lxy x y Lyy y2, x . y 1

4 Lxy2 Lxx Lyy

The discriminant of second order image structure is just the determinant of the Hessian matrix, i.e. theGaussian curvature. Here is our fourth order discriminant:

Discriminant pol4, x . y 1 Simplify

256 27 Lxxxy4 Lyyyy2 Lxxxy3 64 Lxyyy3 108 Lxxyy Lxyyy Lyyyy

12 Lxxxx Lxxxy Lxyyy 9 Lxxyy Lxyyy2 15 Lxxyy2 Lyyyy Lxxxx Lyyyy2 6 Lxxxy2

6 Lxxyy2 Lxyyy2 9 Lxxyy3 Lyyyy Lxxxx Lxyyy2 Lyyyy 9 Lxxxx Lxxyy Lyyyy2

Lxxxx 54 Lxxyy3 Lxyyy2 81 Lxxyy4 Lyyyy 54 Lxxxx Lxxyy Lxyyy2 Lyyyy

18 Lxxxx Lxxyy2 Lyyyy2 Lxxxx 27 Lxyyy4 Lxxxx Lyyyy3

It looks like an impossibly complicated polynomial in fourth order derivative images, and it is. Throughthe use of Gaussian derivative kernels each separate term can easily be calculated. Here is the key pointof the example: We Replace (with the operator /.) all the partial derivatives into scaled Gaussian

derivative convolution functions gD (see previous section) of the appropriate order:

discr4 im_, _ :

Discriminant pol4, x . y 1, Lxxxx gD im, 4, 0, , Lxxxy gD im, 3, 1, ,

Lxxyy gD im, 2, 2, , Lxyyy gD im, 1, 3, , Lyyyy gD im, 0, 4,

We apply this high order function on an image of a checkerboard, and we add noise with twice themaximum image intensity to show its robustness, despite the high order derivatives:

6

Page 7: 2. Computer vision with computer algebra systems

t1 Table If x 50 && y 50 x 50 && y 50 , 0, 100 200 Random ,

x, 1, 100 , y, 1, 100 ;

t2 Table If x y 100 0 && y x 0 x y 100 0 && y x 0 , 0, 100

200 Random , x, 1, 100 , y, 1, 100 ;

FEVinit`; FEVFunctions`;

im 1, 2, 3, 4 , 2, 3, 4, 5 , 3, 4, 5, 6 , 4, 5, 6, 7 ;

Discriminant pol4, x . y 1, Lxxxx gD im, 4, 0, , Lxxxy gD im, 3, 1, ,

Lxxyy gD im, 2, 2, , Lxyyy gD im, 1, 3, , Lyyyy gD im, 0, 4,

59685.7, 4920.9, 4921.71, 59689.8 , 4920.9, 405.712, 405.777, 4921.2 ,

4921.71, 405.777, 405.863, 4922.21 , 59689.8, 4921.2, 4922.21, 59695.3

Discriminant pol4, x . y 1, Lxxxx a, Lxxxy b, Lxxyy c, Lxyyy d, Lyyyy e

256 36 b2 c2 d2 54 a c3 d2 64 b3 d3 108 a b c d3

27 a2 d4 54 b2 c3 e 81 a c4 e 108 b3 c d e 180 a b c2 d e 6 a b2 d2 e

54 a2 c d2 e 27 b4 e2 54 a b2 c e2 18 a2 c2 e2 12 a2 b d e2 a3 e3

gD im, 1, 0, 1

0.457365, 0.457365, 0.457365, 0.457365 ,

0.457365, 0.457365, 0.457365, 0.457365 ,

0.457365, 0.457365, 0.457365, 0.457365 ,

0.457365, 0.457365, 0.457365, 0.457365

discr4 m4x4, 1

59685.7, 4920.9, 4921.71, 59689.8 , 4920.9, 405.712, 405.777, 4921.2 ,

4921.71, 405.777, 405.863, 4922.21 , 59689.8, 4921.2, 4922.21, 59695.3

noisycheck Transpose Join t1, t2 ;

Block $DisplayFunction Identity ,

p1 ListDensityPlot noisycheck, ImageSize 200, 100 ;

p2 ListDensityPlot discr4 noisycheck, 5 , ImageSize 200, 100 ;

Show GraphicsArray p1, p2 , ImageSize 500 ;

Figure 4. Left: A noisy checkerboard detail at two orientations. Right: the output of the 4th orderdiscriminant. The detection clearly is rotation invariant, robust to noise, and there is no detection atcorners (e.g. center of the image).

Note that we have a highly symmetric situation here: the four edges that come together at thecheckerboard vertex cut the angle in four. The symmetry can be seen in the complex expression for

7

Page 8: 2. Computer vision with computer algebra systems

discr4: only pure partial derivatives of fourth order occur. For a less symmetric situation we need adetector which incorporates in its expression also the lower order partial derivatives. The detectedcrossings at the boundaries are no artefact; they are the consequence of the periodic tiling of the imagein all directions in the convolution implementation. For details on the application of algebraic invariantsin computer vision see [Salden1999a].

Another example of the combined use of analytical calculation and automated numericalimplementation by pattern matching is the deblurring of Gaussian blur by inverting the action of thediffusion equation, as originally described by Florack et al. [Florack et al. 1994b].

Gaussian degradation, as deblurring with a Gaussian kernel is also coined, occurs at a large number ofsituations. The point-spread-function of the human lens e.g. has a close to Gaussian shape (for a 3 mmpupil its standard deviation is about 2 minutes of arc, the atmospheric turbulence blurs astronomicalimages in a Gaussian fashion, and the thickness profile of thin slices made by modern spiral-CTscanners is about Gaussian, leading to Gaussian blur in a multiplanar reconstructed image such as in thesagittal or coronal plane. Surely, deblurring is of immediate importance for image restoration. Due to thecentral limit theorem, stating that a concatenation of any type of transformation gives a Gaussian shapewhen the number of sequential transformations goes to infinity, many physical processes involvingsequential local degradations show a close-to-Gaussian blurring.

There is an analytical solution for the inversion of Gaussian blur. But the reconstruction can never beexact. Many practical solutions have been proposed, involving a variety of enhancing filters (e.g. high-pass or Wiener), Fourier methods [Rosenfeld and Kak 1982, Hall 1979, Pratt 1978]. Analytical methodshave been proposed by Kimia, Hummel and Zucker [Kimia et al. 1993a, Hummel 1987a] as well as Reti[Réti 1995a]. They replaced the Gaussian blurkernel by a highly structured Toeplitz matrix anddeblurred the image by the analytical inverse of this matrix. Martens deblurred images with polynomialtransforms [Martens 1990].

If we consider the stack of images in the scale-space, we see the images gradually blur when we increasethe scale. Indeed, the diffusion equation L

t

2Lx2

2Ly2 tells us that the change L in L when we

increase the scale t with a small increment t is equal to the local value of the Laplacian 2Lx2

2Ly2 .

From the early chapters we remember that a scale-space is infinitely differentiable due to theregularization properties of the observation process.

A natural step is to look what happens if we go to negative scales. Due to the continuity we are allowedto construct a Taylor expansion of the scale-space in any direction, including the negative scaledirection. We create a Taylor series expansion of our scale-space L x, y, t

with Mathematica'scommand Series, e.g. to third order around the point t 0:

8

Page 9: 2. Computer vision with computer algebra systems

L .; Series L x, y, t , t, 0, 3

L x, y, 0 L 0,0,1 x, y, 0 t12L 0,0,2 x, y, 0 t2

16L 0,0,3 x, y, 0 t3 O t 4

The derivatives to t are recognized as e.g. L 0,0,1 . It is not possible to directly calculate thederivatives to t . But here the diffusion equation rescues us. We can replace the derivative of the imageto scale with the Laplacian of the image, and that can be computed by application of the Gaussianderivatives on the image. Higher orders derivatives to t have to be replaced with the repeated Laplacianoperator. E.g., the second order derivative to t has to be replaced by the Laplacian of the Laplacian. Toshorten our notations, we define

to be the Laplacian operator:

: x,2 # y,2 # &

Here the construct of a 'pure function' in Mathematica is used: e.g. #3 & is a function without namethat raises its argument to the third power. The repeated Laplacian operator is made with the functionNest:

Nest f, x, 3

f f f x

We now look for each occurrence of a derivative to t . This is the term L 0,0,n_ x, y, 0

where n_

is anything, named n, the order of differentiation to t . The underscore _ or Blank[] is the

Mathematica representation for any single expression). With the now familiar technique of patternmatching (/. is shorthand for the Replace operator) we replace each occurrence of

L 0,0,n_ x, y, 0 with an n-times-nested Laplacian operator as follows:

expr

Normal Series L x, y, t , t, 0, 3 . L 0,0,n_ x, y, 0 Nest , L x, y, 0 , n

L x, y, 0 t L 0,2,0 x, y, 0 L 2,0,0 x, y, 012t2 L 0,4,0 x, y, 0 2 L 2,2,0 x, y, 0 L 4,0,0 x, y, 0

16t3 L 0,6,0 x, y, 0 3 L 2,4,0 x, y, 0 3 L 4,2,0 x, y, 0 L 6,0,0 x, y, 0

In order to get the formulas better readable, we apply pattern matching again: we change the complexnotations of derivatives into a more compact representation, where a higher order derivative is indicatedby a list of dimensional indices:

Off Table::iterb ; Off StringJoin::string ;

expr . Derivative n_, m_, l_ L x_, y_, z_

SubscriptBox L, Table "x", n Table "y", m Table "z", l

DisplayForm

L x, y, 0 t Lxx Lyy12t2 Lxxxx 2 Lxxyy Lyyyy

16t3 Lxxxxxx 3 Lxxxxyy 3 Lxxyyyy Lyyyyyy

9

Page 10: 2. Computer vision with computer algebra systems

Indeed, high order of spatial derivatives appear. The highest order in this example is 6, because weapplied the Laplacian operator 3 times, which itself is a second order operator. With Mathematica wenow have the machinery to make Taylor expansions to any order, e.g. to 8:

expr

Normal Series L x, y, t , t, 0, 8 . L 0,0,n_ x, y, 0 Nest , L x, y, 0 , n ;

expr . Derivative n_, m_, l_ L_ x_, y_, z_ SubscriptBox L,

Table "x", n Table "y", m Table "z", l DisplayForm

L x, y, 0 t Lxx Lyy12t2 Lxxxx 2 Lxxyy Lyyyy

16t3 Lxxxxxx 3 Lxxxxyy 3 Lxxyyyy Lyyyyyy

124

t4 Lxxxxxxxx 4 Lxxxxxxyy 6 Lxxxxyyyy 4 Lxxyyyyyy Lyyyyyyyy

1120

t5 Lxxxxxxxxxx 5 Lxxxxxxxxyy 10 Lxxxxxxyyyy 10 Lxxxxyyyyyy 5 Lxxyyyyyyyy Lyyyyyyyyyy

1720

t6 Lxxxxxxxxxxxx 6 Lxxxxxxxxxxyy 15 Lxxxxxxxxyyyy

20 Lxxxxxxyyyyyy 15 Lxxxxyyyyyyyy 6 Lxxyyyyyyyyyy Lyyyyyyyyyyyy1

5040t7 Lxxxxxxxxxxxxxx 7 Lxxxxxxxxxxxxyy 21 Lxxxxxxxxxxyyyy 35 Lxxxxxxxxyyyyyy

35 Lxxxxxxyyyyyyyy 21 Lxxxxyyyyyyyyyy 7 Lxxyyyyyyyyyyyy Lyyyyyyyyyyyyyy1

40320t8 Lxxxxxxxxxxxxxxxx 8 Lxxxxxxxxxxxxxxyy 28 Lxxxxxxxxxxxxyyyy

56 Lxxxxxxxxxxyyyyyy 70 Lxxxxxxxxyyyyyyyy 56 Lxxxxxxyyyyyyyyyy28 Lxxxxyyyyyyyyyyyy 8 Lxxyyyyyyyyyyyyyy Lyyyyyyyyyyyyyyyy

No matter how high the order of differentiation, the derivatives can be calculated using the multiscaleGaussian derivative operators. So, as a final step, we express the spatial derivatives in the formula abovein the Gaussian derivatives, again using the technique of pattern matching (HoldForm assures we see

just the formula for gD[], of which evaluation is 'hold'; ReleaseHold removes the hold):

10

Page 11: 2. Computer vision with computer algebra systems

corr expr . Derivative n_, m_, 0 L x, y, a_ HoldForm gD im, n, m, 1

t gD im, 0, 2, 1 gD im, 2, 0, 112t2 gD im, 0, 4, 1 2 gD im, 2, 2, 1 gD im, 4, 0, 1

16t3 gD im, 0, 6, 1 3 gD im, 2, 4, 1 3 gD im, 4, 2, 1 gD im, 6, 0, 1

124

t4 gD im, 0, 8, 1 4 gD im, 2, 6, 1

6 gD im, 4, 4, 1 4 gD im, 6, 2, 1 gD im, 8, 0, 11

120t5 gD im, 0, 10, 1 5 gD im, 2, 8, 1 10 gD im, 4, 6, 1

10 gD im, 6, 4, 1 5 gD im, 8, 2, 1 gD im, 10, 0, 11

720t6 gD im, 0, 12, 1 6 gD im, 2, 10, 1 15 gD im, 4, 8, 1 20 gD im, 6, 6, 1

15 gD im, 8, 4, 1 6 gD im, 10, 2, 1 gD im, 12, 0, 11

5040t7 gD im, 0, 14, 1 7 gD im, 2, 12, 1 21 gD im, 4, 10, 1 35 gD im, 6, 8, 1

35 gD im, 8, 6, 1 21 gD im, 10, 4, 1 7 gD im, 12, 2, 1 gD im, 14, 0, 11

40320t8 gD im, 0, 16, 1 8 gD im, 2, 14, 1 28 gD im, 4, 12, 1

56 gD im, 6, 10, 1 70 gD im, 8, 8, 1 56 gD im, 10, 6, 1

28 gD im, 12, 4, 1 8 gD im, 14, 2, 1 gD im, 16, 0, 1 L x, y, 0

Because we deblur, we take for t 12

2 a negative value, given by the amount of blurring estimated weexpect we have to deblur. However, applying Gaussian derivatives on our image increases the innerscale with the scale of the applied operator, i.e. blurs it a little necessarily. So, if we calculate ourrepeated Laplacians say at scale operator 4, we need to deblur the effect of both blurrings. Expressed

in t , the total deblurring 'distance' amounts to tdeblur2

estimated2

operator

2 . We assemble our commands in asingle deblurring command which calculates the amount of correction to be added to an image to deblurit:

deblur[im_, est_, order_, _] := Module[{expr},

=D[#1,{x,2}]+D[#1,{y,2}]&; expr = Normal[Series[L[x, y, t], {t, 0, order}]]/.

Derivative[0, 0, l_][L_][x_, y_, t_] :> Nest[ , L[x, y, t], l] /. t -> -( est^2+ ^2)/2; Drop[expr,1]/.Derivative[n_,m_,0][L][x,y,t_]

HoldForm[gD[im,n,m, ]]]

and test it, e.g. for first order:

im .; deblur im, 2, 1, 2

4 gD im, 0, 2, 2 gD im, 2, 0, 2

It is a well known fact in image processing that subtraction of the Laplacian (times some constantdepending on the blur) sharpens the image. We see here that this is nothing else then the first orderresult of our deblurring approach using scale-space theory. For higher order deblurring the formulas getmore complicated and higher derivatives are involved:

11

Page 12: 2. Computer vision with computer algebra systems

deblur im, 2, 3, 2

4 gD im, 0, 2, 2 gD im, 2, 0, 2

8 gD im, 0, 4, 2 2 gD im, 2, 2, 2 gD im, 4, 0, 2323

gD im, 0, 6, 2 3 gD im, 2, 4, 2 3 gD im, 4, 2, 2 gD im, 6, 0, 2

We generate a testimage blurred with 2 pixels and display it both below as in a new window forlater easy comparison:

im rasterpixels Import "mr128.gif" ; blur gDf im, 0, 0, 2 ;

ListDensityPlot blur, DisplayFunction displayNewNotebook ;

ListDensityPlot blur, ImageSize 128 ;

Figure 5. Input image for deblurring, blurred at

= 2 pixels. Image resolution 1282 .

We try a deblurring for orders 4, 8, 16 and 32, and measure how long the computations take:

Timing

Block $DisplayFunction Identity ,

p1 ListDensityPlot blur, PlotLabel "original" ;

p2 Table corr deblur blur, 2, 2i, 4 ReleaseHold;

ListDensityPlot blur corr,

PlotLabel "order " ToString 2i , i, 2, 5 ;

Show GraphicsArray Prepend p2, p1 , ImageSize 550 1

original order 4 order 8 order 16 order 32

0.88 Second

Mathematica is reasonably fast: the deblurring to 32nd order involved derivatives up to order 64 (!), in apolynomial containing 560 calls to the gD derivative function. The 4 calculations above take together

about 4.5 minutes for a 1282 image on a 500 MHz 128 MB Pentium III under Windows 98 (the 32nd

order case took 3.5 minutes). This counts the occurrences of gD in the 32nd order deblur polynomial, i.e.

how many actual convolutions of the image were needed:

12

Page 13: 2. Computer vision with computer algebra systems

dummy .; Length Position deblur dummy, 2, 32, 4 , gD

560

Differential operators are differentiating in a particular direction, typically in the direction of thecoordinate axes: the basis directions. Partial derivative operators in an arbitrary direction can be foundfrom a polynomial combination of such basis directions [Freeman 1990a]. Here we present a frameworkfor generating such directional derivative operators.

The coordinate frame in each position is rotated into the required direction. In stead of a locally adaptiveset of directions for our frame to the orientation of the gradient vectorfield, we now choose a fixedrotation of our frame vectors. The vector differential nabla operator {D[#,x],D[#,y]}& is taken in

the direction of the vector {v,w} through a dot-product, and rotated with a rotationmatrix

or

and

normalized, to form resp. the dv and dw directional operator:

RotationMatrix2D 0 ; RotationMatrix2D 2 ;

dw1

v2 w2v, w . . D #, x , D #, y &;

dv1

v2 w2v, w . . D #, x , D #, y &;

Such derivatives, locked to specific local directions (as in this case tangent and gradient), are calledgauge derivatives.

We notice that the orientation of the unitvector frame {v,w} is given by {Sin[ ],Cos[ ]} where

is our required angle of rotation. We define gD [im_,nv_,nw_, _, _], our rotated Gaussian

derivative operator, in the appropriate way by repeated action of the differential operators (with Nest)

on some function L[x,y] and thereafter replacing the fixed direction {v,w} with the particular choice

of {Sin[ ],Cos[ ]}. A final step is the replacement of any appearance of a derivative of the

function L[x,y] into the regular multiscale Gaussian derivative operator gD, through the use of

Mathematica's pattern matching operator Replace:

gD im_, nv_, nw_, _, _ :

Nest dw, Nest dv, L x, y , nv , nw . v Sin , w Cos .

Derivative n_, m_ L x, y HoldForm gD im, n, m, Simplify

Some examples: Here is the third derivative Gx x x rotated over 6 (30 degrees clockwise), theexample of the beginning of this chapter, both in explicit formula and plotted at a scale of 15 pixels(1282 image):

im .; gD im, 3, 0, 15, 6

13

Page 14: 2. Computer vision with computer algebra systems

Convolution of a kernel with a -function (spike image) returns the kernel itself, here at a large scale=15 pixels:

im Table 0, 128 , 128 ; im 64, 64 100;

DisplayTogetherArray ListDensityPlot gD im, 3, 0, 15 ,

ListDensityPlot gD im, 3, 0, 15, 6 ReleaseHold ;

Figure 6. Left: the third order Gaussian derivative kernel to x . Right: the same kernel rotated 30 degreesclockwise, calculated from the expression in partial Cartesian derivatives above.

This is an exact multiscale directional derivative. Any angle can now readily be constructed for anyorder partial derivative. The often encountered limit 'only in 8 directions' of direct neighbourdifferences is no longer restrictive.

The construction of a directional derivative kernel from the Cartesian basis is depicted in figure 7.

im Table 0, 128 , 128 ; im 64, 64 100;

Block $DisplayFunction Identity , p1

Apply ListDensityPlot gD im, #1, #2, 15 &, 3, 0 , 1, 2 , 2, 1 , 0, 3 , 2 ;

p2 ListDensityPlot gD im, 3, 0, 15,6

ReleaseHold ;

t1 Graphics Text StyleForm " ", Title , 0, 0 ;

tt1 Flatten p1, t1, p2 ;

Show GraphicsArray tt1 , ImageSize 550 ;

Figure 7. From a basisset of Cartesian x, y-separable Gaussian derivative kernels a partial derivativeoperator can be constructed in any direction. The weights are calculated in the section above. Kernel thesame as in figure 16.4.

Here is Mathematica's construction of a 4th order derivative under an angle of /10:

14

Page 15: 2. Computer vision with computer algebra systems

im .; gD im, 2, 2, 15, 10

132

5 5 gD im, 0, 4, 15

4 2 5 5 gD im, 1, 3, 15 2 gD im, 2, 2, 15 6 5 gD im, 2, 2, 15

4 2 5 5 gD im, 3, 1, 15 5 gD im, 4, 0, 15 5 gD im, 4, 0, 15

It has been shown that the Eigenimages of a large series of image small patches have great similarity topartial Gaussian derivative functions [Olshausen and Field 1996, 1997]. The resulting images are alsooften modeled as Gabor patches and wavelets. In this section we will study this statistical technique withMathematica.

We read the many patches as small square subimages of =12x12 pixels, non-overlapping, at 17horizontal and 17 vertical position, leading to a series of 289 patches. Figure 9.8 shows the location ofthe patches. These 289 images form the input set.

im Import "mr256.gif" 1, 1 ; 12; ListDensityPlot im,

Epilog White, Table Line i, j , i , j , i , j , i, j , i, j ,

j, 2, 256, 15 , i, 2, 256, 15 ;

Figure 8. Location of the 289 small 12x12 pixel patches taken from a 2562 sagittal MR scan

The small 12x12 images are sampled with SubMatrix and converted into a matrix m with 289 single

colums of length 144:

15

Page 16: 2. Computer vision with computer algebra systems

set Table SubMatrix im, j, i , , , j, 2, 256, 15 , i, 2, 256, 15 ;

m Flatten Map Flatten, set, 2 , 1 Transpose; Dimensions m

144, 289

We calculate mT m , a 2892 matrix with the Dot product:

Dimensions mTm N Transpose m .m

289, 289

The calculation of the 289 Eigenvalues of a 2892 matrix goes fast in Mathematica. Essential is to forcethe calculations to be done numerically with the function N[]. Most of the Eigenvalues are very small.

We chop all values less then 10 7 .

Timing eigenvalues Chop Eigenvalues mTm , 10 7 ; 1

Short eigenvalues, 8

2.31 Second

2.88488 108, 1.36663 107, 7.88379 106, 3.7702 106,

3.13123 106, 2.87957 106, 1.61115 106, 1.30582 106, 1.03305 106,

889077., 745678., 654591., 550406., 510187., 454268., 379557.,

313759., 255 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

We plot the reals in the list on a log scale, and see that the larger Eigenvalues decrease exponentially,and the smaller Eigenvalues deviate from this behaviour:

LogListPlot Cases eigenvalues, _Real , PlotJoined True ;

0 20 40 60 80 100 120 140

100

10000

1. 106

1. 108

Figure 9. Nonzero Eigenvalues for the MR sagittal slice patches.

We calculate the Eigenvectors of the matrix mTm and construct the first Eigenimage by calculating

the inner product of the first Eigenvector and the matrix m with the 298 image patches. All Eigenvectors

are normalized, have unity length. The resulting 144x1 vector is partitioned into 12 rows to reconstructthe patch again. We plot the first 8 Eigenimages and their heigth plot:

16

Page 17: 2. Computer vision with computer algebra systems

eigenvectors Eigenvectors mTm ;

eigenimages Table Partition m.eigenvectors i , , i, 1, 8 ;

DisplayTogetherArray ListDensityPlot eigenimages, ImageSize 550 ;

DisplayTogetherArray ListPlot3D eigenimages, ImageSize 550 ;

Figure 10. The first 8 Eigenimages of the 289 patches from figure 9.8. Note the resemblance of thesecond and third Eigenimage to the first order Gaussian derivatives G

x

and Gy , and the 4th, 5th and

6th Eigenimage to the second order Gaussian derivatives 2Gx2 under 120 degree different angles. We

will derive in chapter 16 that a second order Gaussian derivative in any direction can be constructedfrom 3 second order partial derivative kernels each 120 degrees rotated (this is the steerability ofGaussian kernels).

The Eigenimages reflect the basis functions in which the spatial structure of the images can beexpressed. The natural basis for spatial image structure are the spatial derivatives emerging in the localTaylor expansion. When there is no coherent structure, such as in white noise, we get Eigenimages thatreflect just noise.

The image structure leads to a different basis for different scales of observation, in other words fordifferent patch sizes. We investigate 3 patch sizes in the figure below:

im Import "mr256.gif" 1, 1 ;

Table

set Table SubMatrix im, j, i , , , j, 2, 256, 15 , i, 2, 256, 15 ;

m Flatten Map Flatten, set, 2 , 1 Transpose;

eigenvectors Eigenvectors N Transpose m .m ;

eigenimages Table Partition m.eigenvectors i , , i, 1, 8 ;

DisplayTogetherArray ListDensityPlot eigenimages, ImageSize 550 ;,

, 8, 14, 3 ;

17

Page 18: 2. Computer vision with computer algebra systems

Figure 11. The first 8 Eigenimages for 3 different patch sizes. Top: patchsize = 8x8 pixels. Middle:patchsize = 11x11 pixels, Bottom: patchsize = 14x14 pixels. Note the reverse in polarity of the secondEigenimage in the bottom row.

For the calculation of an image warping the image has to be resampled, often at points in between theoriginal points. Mathematica has the function Interpolation and for discrete data

ListInterpolation that interpolates a function (of any dimension) to some order (default is cubic

spline inperpolation: to third order). This function comes handy for any resampling.

Here is the implementation of a warping routine for 2D images given a 2D invertible vectorfield:

deform2D im_List, vecf_List : Module xdim, ydim, m, imp, newx, newy ,

ydim, xdim Dimensions im ; m Table 0, ydim , xdim ;

imp ListInterpolation im ; Do newx x vecf x, y, 2 ;

newy y vecf x, y, 1 ; If 1 newx xdim &&

1 newy ydim, m x, y imp newx, newy , m x, y 0 ,

y, 1, ydim , x, 1, xdim ; m ;

We read a 2562 image of a retinal fundus and plot the image and an example vectorfield. The sampled,discrete vectorfield vecf is calculated and the resulting warped image is shown below:

18

Page 19: 2. Computer vision with computer algebra systems

im Import "fundus256.gif" 1, 1 ;

Graphics`PlotField`; ydim, xdim Dimensions im ;

vecf Table N Sin x xdim , Cos y ydim , y, 1, ydim , x, 1, xdim ;

DisplayTogetherArray Show

ListDensityPlot im , PlotVectorField Sin x xdim , Cos y ydim ,

x, 1, xdim , y, 1, ydim , DefaultColor RGBColor 1, 0, 1 ,

ListDensityPlot deform2D im, 20 vecf , ImageSize 550 ;

Figure 12. Left: Image of a retina fundus registered with a scanning laser ophthalmoscope (courtesy T.Berendschot, University Medical Center Utrecht, the Netherlands). Image resolution 2562 .Superimposed are vectors of a given warping vectorfield. Right: The deformed or warped image. Thenew image intensities are sampled from the cubic spline-interpolated image at a position dislocated overthe distance of the vectors.

The application of adaptive, geometry-driven evolution of images through the use of nonlinear diffusionequations was intiated by a seminal paper by Perona and Malik [Perona1991]. They introduced aconductivity term in the diffusion equation, that was a function of the gradient strength weighted with afactor k . At locations of high gradient strength the conductivity, and thus the diffusion, was reduced, tokeep the gradient mostly touched and blurring (denoising) the more homogeneous areas. The PDE basednonlinear enhancement of images has become a field in its own [ter Haar Romeny 1994].

Alvarez, Guichard, Lions and Morel [Alvarez 1992a] realized that the Perona & Malik variableconductance diffusion was complicated by the choice of the parameter k . They reasoned that theprincipal influence on the local conductivity should be to direct the flow in the direction of the gradientonly: we want a lot of diffusion along the edges, but virtually no diffusion across the edges. This led to

19

Page 20: 2. Computer vision with computer algebra systems

the proposal to make the intensity flow a function of the unit gradient vector L

Lcos , sin , so

we get the (nonlinear) diffusion equation

Ls L . L

L

In Mathematica:

Calculus`VectorAnalysis`; SetCoordinates Cartesian x, y, z ;

L Grad L x, y, 0 ; L . L DivL

L. LSimplify shortnotation

2 Lx Lxy Ly Lxx Ly2 Lx

2 LyyLx2 Ly2

This is exactly L , i.e. the isophote curvature

times the gradient magnitude L . Theenthousiasm of Alvarez et al. about this equation led them to the name 'fundamental equation of imageprocessing' (!). This PDE is better known as the Euclidean shortening flow equation, for reasons we willdiscuss in the next section.

There are a number of differences between this equation and the Perona & Malik equation:- the flow (of flux) is independent of the magnitude of the gradient;- There is no extra free parameter, like the edge-strength turnover parameter k ;- in the Perona & Malik equation the diffusion decreases when the gradient is large, resulting in contrastdependent smoothing;- this equation is gray-scale invariant.

Grayscale invariance

A function is grayscale invariant, if the function does not change value when the grayscale function L ismodified by a monotonically increasing or decreasing function f L , f 0. Grayscale invariance is anattractive property: image analysis is the same when we change e.g. the contrast or brightness on amonitor, or if we put up sunglasses. The gradient is dependent on f :

Clear f, L ; u f L x, y, s ; gradu x u2

y u2

f L x, y, s 2 L 0,1,0 x, y, s2

f L x, y, s 2 L 1,0,0 x, y, s2

The Euclidean shortening flow equation Ls L . L

L

is independent of f :

FullSimplify s u gradu xx u

graduy

y u

gradu0, f' L x, y, s 0

shortnotation

2 Lx Lxy Ly Lxx Ly2 Ls Lx

2 Ly2 Lx

2 LyyLx2 Ly2

0

20

Page 21: 2. Computer vision with computer algebra systems

The mapping f has disappeared from the equation: the equation is greyscale invariant.

Numerical examples

We study some numerical examples of this PDE on a simple image. We first define the numericaliterative approximation to the nonlinear PDE:

euclideanshortening im_, nrsteps_, _, evolutionrange_ :

Module s, imt , s evolutionrange nrsteps; imt im;

Do imt s gD imt, 0, 2, gD imt, 1, 0, 2 2 gD imt, 0, 1,

gD imt, 1, 0, gD imt, 1, 1, gD imt, 0, 1, 2 gD imt, 2, 0,

gD imt, 0, 1, 2 gD imt, 1, 0, 2 , nrsteps ; imt ;

In gauge coordinates the expression becomes more compact:

euclideanshortening im_, nrsteps_, _, evolutionrange_ :

Module s, imt , s evolutionrange nrsteps; imt im;

Do imt s gauge2D imt, 0, 2, ReleasHold, nrsteps ; imt ;

We study the disk image again, now with additive uniform pixel-uncorrelated noise:

disk Table If x 64 2 y 64 2 1000, 1, 0 Random , y, 128 , x, 128 ;

diskblurred gD disk, 0, 0, 128 ;

DisplayTogetherArray

ListDensityPlot disk , ListDensityPlot diskblurred , ImageSize 300 ;

Figure 13. Noisy disk image. Image resolution 1282 , disk=1, background=0, noise amplitude [0-1]. Right:image blurred with 128 , or s 64 with linear Gaussian diffusion. By blurring the image the noise isgone, but the edge is gone too.

The critical timestep (Von Neumann limit) for this numerical scheme is tx 2 s . We check this with

the same settings as above for the linear diffusion example:

21

Page 22: 2. Computer vision with computer algebra systems

Block $DisplayFunction Identity ,

p1 Table ListDensityPlot euclideanshortening disk, nsteps, .8, 64 ,

PlotLabel "timestep " ToString N 64 nsteps , nsteps, 32, 40, 2 ;

Show GraphicsArray p1 , ImageSize 550 ;

timestep 2. timestep 1.88235 timestep 1.77778 timestep 1.68421 timestep 1.6

Figure 14. Euclidean shortening flow on the noisy disk image for a range of timestep sizes around thecritical timestep s 0.82 1.74. Clearly artefacts emerge for timestep sizes larger than the criticaltimestep.

And here is the evolution itself (we choose s 1.6 pixels2 as timestep) for s 1 to 49 in 4 steps, withthe scale of the flux operator 0.8:

Block $DisplayFunction Identity ,

p1 Table nsteps Ceiling s 1.6 ;

ListDensityPlot euclideanshortening disk, nsteps, .8, s ,

PlotLabel "time " ToString s , s, 1, 49, 16 ;

Show GraphicsArray p1 , ImageSize 550 ;

time 1 time 17 time 33 time 49

Figure 15. Euclidean shortening flow on the noisy disk image as a function of evolution time/scale (inpixel2 ). The noise is significantly reduced, while the edge is preserved.

We see the noise gradually disappearing in this nonlinear scale-space evolution, while the edge strengthis well preserved. Because the flux term, expressed in Gaussian derivatives, is rotation invariant, theedges are well preserved irrespective of their direction. This is an example of edge-preserving

smoothing.

22

Page 23: 2. Computer vision with computer algebra systems

Block $DisplayFunction Identity ,

p1 ListPlot disk 64 , PlotJoined True, PlotLabel "original" ;

p2 ListPlot euclideanshortening disk, 32, .8, 32 64 ,

PlotJoined True, PlotLabel "time 31" ;

Show GraphicsArray p1, p2 , ImageSize 400 ;

20 40 60 80 100 120

0.5

1

1.5

2original

20 40 60 80 100 120

0.2

0.4

0.6

0.8

1

1.2

1.4

time 31

Figure 16. Plot of the middle horizontal row of pixel intensity values for the original noisy disk image (left)and the image at time t 31 with Euclidean shortening flow. Note the little overshoot at the edges, andthe excellent noise removal while keeping a steep edge.

This is an example for an ultrasound image with its particular speckle pattern:

us Import "us.gif" 1, 1 ;

Block $DisplayFunction Identity, s 9 ,

p1 ListDensityPlot us, PlotLabel "Original" ;

p2 ListDensityPlot use euclideanshortening us, 6, .8, s ,

PlotLabel "scale " ToString s ;

Show GraphicsArray p1, p2 , ImageSize 550 ;

Original scale 9

Figure 17. Euclidean shortening flow on a 260 x 345 pixel ultrasound image (source: www.atl.com).

Many improvements and accelleration schemes have been proposed recently. It is beyond the scope ofthis paper to discuss these developments in detail. Good references to study are: Kacur and Mikula[Kacur2001], Weickert et al. [Weickert1997e, Weickert1998b].

23

Page 24: 2. Computer vision with computer algebra systems

4. Conclusions

We have shown a number of applications where the combined symbolic and numerical strengths ofMathematica are indispensible for doing rapid prototyping research. The applications are characterizedby a mathematical formulation, which is solved first, and with a pattern matching technique thenumerical operators working on the images are constructed. Expansion of the examples to include othersettings for the parameters (differential order, scale, etc.) is straightforward. All code is availableimmediately with the describing text.

This may be the beginning of a trend in computer vision research, where labour intensive medium levelprogramming is replaced by relatively fast and compact high level programming. It invites to efficientand above all -interactive- experimentation. The advent of parallel computing for computer algebrapackages makes this perspective even more attractive.

References

A. H. Salden, B. M. ter Haar Romeny, and M. A. Viergever, "Algebraic invariants oflinear scale spaces." Journal of Mathematical Imaging and Vision, March 1999.

D. Hilbert, "Über die Theorie der algebraischen Formen", Math. Annalen, vol. 36, pp. 473-534, 1890.

L. M. J. Florack, B. M. ter Haar Romeny, J. J. Koenderink, and M. A. Viergever, "Linear scale-space", Journal of Mathematical Imaging and Vision, vol. 4, no. 4, pp. 325-351, 1994.

Z. Réti, "Deblurring images blurred by the discrete Gaussian", AML, vol. 8, no. 4, pp. 29-35, 1995.

J. B. Martens, "Deblurring digital images by means of polynomial transforms", Computer Vision, Graphics, and Image and Stochastic Processing, vol. 50, pp. 157-176, 1990.

W. T. Freeman and E. H. Adelson, "Steerable filters for early vision, image analysis and wavelet decomposition", in Proc. 3rd Int. Conf. on Computer Vision, (Osaka, Japan), IEEE Computer Society Press, December 1990.

L. Alvarez, P. L. Lions, and J. M. Morel, "Image selective smoothing and edge detection by nonlinear diffusion. II", SIAM Journal on Numerical Analysis, vol. 29, pp. 845-866, June 1992.

J. Kacur, K. Mikula, "Slow and fast diffusion effects in image processing", Computing and Visualization in Science, Springer Berlin, vol. 3, nr. 4, 2001.

J. Weickert, K. J. Zuiderveld, B. M. ter Haar Romeny, and W. J. Niessen, Parallelimplementations of AOS schemes: A fast way of nonlinear diffusion filtering", in Proc.1997 IEEE Int. Conf. Image Processing, vol. 3, (ICIP-97, Santa Barbara, Oct. 26-29,1997), pp. 396-399, 1997.

24

Page 25: 2. Computer vision with computer algebra systems

J. Weickert, B. M. ter Haar Romeny, and M. A. Viergever, "Efficient and reliableschemes for nonlinear diffusion filtering", IEEE Tr. on Image Processing, Vol. 7,398-410, 1998.

L. M. J. Florack, "Image structure", Kluwer Academic Publishers, Dordrecht, the Netherlands, 1997.

L. M. J. Florack, B. M. ter Haar Romeny, J. J. Koenderink, and M. A. Viergever, "Cartesian differential invariants in scale-space", Journal of Mathematical Imaging and Vision, vol. 3, pp. 327-348, November 1993.

J. J. Koenderink, "The structure of images", Biological Cybernetics, vol. 50, pp. 363-370, 1984.

B. M. ter Haar Romeny (ed.), "Geometry-driven diffusion in computer vision".Dordrecht: Kluwer Academic Publishers, 1994.

T. Lindeberg, "Scale-Space Theory in Computer Vision". The Kluwer Intern. Series in Engineering and Computer Science, Dordrecht, the Netherlands: Kluwer Academic Publishers, 1994.

B. A. Olshausen and D. J. Field, "Emergence of simple-cell receptive field properties by learning a sparse code for natural images". Nature, 381: 607-609, 1996.

B. A. Olshausen and D. J. Field, "Sparse coding with an overcomplete basis set: A strategy employed by V1?", Vision Research, 37: 3311-3325, 1997.

J. Sporring, M. Nielsen, L. Florack, and P. J. (Eds.), "Gaussian Scale-Space". Dordrecht: Kluwer Academic Publishers, 1996.

Appendix

The initialization of the Mathematica programs is done with the following initialization fileFEVinit.m:

25

Page 26: 2. Computer vision with computer algebra systems

The $Path variable is appended with the path to the notebooks

If Cases $Path, "d:\\FrontEndVision\\Data\\" ,

$Path Append $Path, "d:\\FrontEndVision\\Data\\" , Null ;

Additional packages are only loaded when needed

Needs "Graphics`" ;

Needs "LinearAlgebra`MatrixManipulation "̀ ;

Needs "Statistics`DataManipulation`" ;

Needs "Graphics`Animation`" ;

Needs "Utilities`FilterOptions`" ;

Options for many functions to our preference for shorter commands

SetOptions ListDensityPlot, Mesh False, PlotRange All, Frame False,

AspectRatio Automatic ;

SetOptions ListContourPlot, PlotRange All, Frame False,

ContourShading False ;

SetOptions ListPlot3D, PlotRange All, Axes False ;

SetOptions Plot3D, PlotPoints 30, PlotRange All,

BoxRatios 1, 1, .6 , Boxed False,

Axes False, ViewPoint 0.950, 2.985, 1.280 ;

SetOptions DensityPlot, Mesh False, PlotRange All, Frame False,

PlotPoints 128, AspectRatio Automatic ;

SetOptions ContourPlot, PlotRange All, ContourShading False ;

SetOptions Arrow, HeadScaling Relative, HeadWidth 0.3 ;

SetOptions ShadowPlot3D, ColorFunction GrayLevel, PlotRange All ;

SetOptions Integrate, GenerateConditions False ;

SetOptions PaddedForm, NumberPadding "0", "0" , NumberSigns "", "" ;

Off Table::iterb ; Off StringJoin::string ;

Off General::spell1 ;

Off Solve::ifun ;

To optimize memory conservation

Share ; $HistoryLength 10;

Style for all graphics and plots lettering to Times, size 7 points

$TextStyle FontFamily "Times", FontSize 7 ;

26

Page 27: 2. Computer vision with computer algebra systems

This document was created with Win2PDF available at http://www.daneprairie.com.The unregistered version of Win2PDF is for evaluation or non-commercial use only.