iterated function systems and two-dimensional shape ... · pdf fileiterated function systems...

Post on 11-Mar-2018

219 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Iterated Function Systemsand Two-Dimensional Shape Representation

P.A.GiIes, A.Purvis(Electrical and Electronic Group)

D. Waugh, R. Garigliano(Computer Science Group)

School of Engineering and Applied Science, Durham University,Science Laboratories, South Road,

Durham, DH1 3LE.

An application of Iterated Function Systems to theproblem of automatic generation of two-dimensionalshape representation is presented. A definition of anIterated Function System is given, and the propertiesthat make it suitable for shape representation aredescribed. Details of programs implementing shapecoding and rendering are provided together with anassessment of their performances.

A fundamental requirement of any vision system designedto perform recognition tasks is a library of representationsof objects it is likely to encounter. The classic approach toconstructing such representations is to decompose theshape into simple primitive elements. However, forcomplex shapes it is usually necessary to use a largenumber of such primitives to achieve an accuratedecomposition. The alternative is to define more complex,context-specific primitives, which would be of practicaluse for only a small set of shapes. The advantage of usingan Iterated Function System (IFS) instead is that it enablesus to construct a recursive definition of shape. This isachieved by using contractive affine transformations of theoriginal shape as the primitives in its decomposition, andthus removing the need for shape primitives to be definedprior to encoding.

As a first approximation an IFS coding can be thought ofas simply a compact list of numbers corresponding to thetransform coefficients that describe how a shape mapsinto itself - in effect how the shape can be covered by acollage of smaller versions of itself. These numbers canthen be used by a very simple rendering algorithm toproduce a reconstruction of the whole of the original shape.This reconstruction is known as the 'attractor' of the IFS.The rendering process is rapid, stable, and does not dependon any information external to the IFS to enable accuratereconstruction. The nature of the IFS code enables therendering of a shape with the same speed and accuracyindependent of the size and orientation required.

Previous applications of IFS theory to shape encoding[1,2,3], have relied heavily on the interaction of the userwith computer programs in order to make the necessaryshape collages, and in the case of [3], coding was restrictedto shapes that were self-similar and that lend themselveseasily to the IFS coding technique. The methods outlined inour paper constitute an entirely automatic way ofproducing IFS codings.

Section 1 of this paper gives the definition of an IFS andshows how in theory it is possible for one to describe anyshape. Section 2 details the programs used in theimplementation of IFS theory for both coding andrendering, and section 3 gives preliminary results from

their use. Section 4 contains a discussion of the progressmade so far and the directions future research needs totake.

1. ITERATED FUNCTION SYSTEMS

This section defines what we mean by an Iterated FunctionSystem and demonstrates how it can be used to represent ashape. For brevity the following is not mathematicallyrigorous, but a full derivation starting from first principlescan be found in [1].

Definition: A hyperbolic Iterated Function System consistsof a complete metric space (X, d), together with a finite setof contraction mappings, wn(X), with respectivecontractivity factors sn, for n = 1, 2, ..., N. The notation for

an IFS is:{ X : w n , n = l , 2 , . . . , N } ,

and its contractivity factor is:

s = max {sn : n = 1,2, . . . , N}.

For applications in two-dimensions the space, X, issimply the Euclidean Plane and d, the standard Euclideanmetric function. The wn are just transformations whichmap points closer together by a factor determined by theircontractivities s,,, which take values in the range (0,1].

The important property of an IFS is that if we define thetransform W(A) to be:

W(A) = w0 (A) U w^A) U w2(A) U . . . U wN(A),

where A is a bounded region in the plane, then the sequenceof regions AQ, AJ, A2,. . ., Am given by iteratively applyingW to A such that:

, k = 0, 1,2, . . . . m,Ak = Wk(A) =

where W0(A) = A has a limit, L, as m approaches infinity.

That is:W(L) = L.

This limit region is called the attractor of the IFS.

We say that an IFS represents a given shape if that shapeis the attractor of the IFS. Physically then, therepresentation will consist of a list of transformcoefficient values.

49 AVC 1989 doi:10.5244/C.3.9

IFS Coding

The problem now is to be able to find the IFS of a givenregion in the plane. The solution is provided by the CollageTheorem [1,2,4,5], which states that for a given region, A:

h(LA) < (1-s) -1 h(A,W(A)) for all A,

where h is the Hausdorf metric function, L the attractor,and s, the contractivity factor of the IFS.

Put simply, the theorem says that as the union of themappings of the IFS becomes 'closer' to the original regionA, so the attractor of the IFS becomes closer to A also.Thus, all that we need to do is to make a 'collage' of thegiven region using contractive mappings of itself.

Attractor Generation

From the derivation in the previous section it is apparentthat given an IFS the corresponding attractor can begenerated by iteratively applying the associated set ofmappings to an arbitrary starting region. However, this willbecome an inefficient process when the number oftransforms becomes very large or when the convergence tothe attractor is slow. An alternative method, described byBarnsley [1,2], requires a modification of the basic IFS inthat a probability, pn, is associated with each of the

mappings, wn. The notation for the modified IFS is:

{ X : ( w n , p n ) , n = l , 2 , . . . , N } .

The attractor of this IFS can now be obtained using thefollowing Random Iteration Algorithm:

1. Take an initial point in the plane, x0. Although the choice

of this point can be made arbitarily it is best if it liessomewhere on the attractor.

2. One of the transformations from the IFS is chosen 'atrandom' with the probability of choosing wn being pn.

3. The selected transformation is applied to the point x0 to

produce the point x}.randomly and applied to

Another transform is chosenj to produce x2, and so on.

4. The process is repeated for a large number of iterationsand the set of points {x0, Xj, . . ., xn) that is produced willconstitute an approximation of the attractor of the IFS. (Itis only an approximation since it contains only a finitenumber of points).

The values of the probabilities of the transforms can bechosen arbitarily but to ensure an even distribution ofpoints over the attractor the they should be in proportion tothe area of the coded region that each covers.

The implementation of the Random Iteration Algorithm isdiscussed in the next section together with a program thatcalculates the IFS of a given shape.

2. IMPLEMENTATION

The implementation of IFS coding and rendering of theattractor has been attempted using ITEX 150 imageprocessing hardware with a Sun 3/75 workstation running

C software under the UNIX operating system. Initialattempts at producing codings have been conducted uponsimple shapes in binary images generated by the systemsgraphics capabilities.

Automatic Coding

The approach taken has been to concentrate on getting thebest fit collage to the boundary of a given region tomaximise the accuracy of the shape information. Theoperation of the coding program can be broken down intothe following stages:

1. The boundary points of the given shape are detectedusing a simple edge following algorithm. An arc-lengthvalue is calculated for each point and the centroid of theshape is determined.

2. At each boundary point the value of dr/ds is calculated,where r is the radius value of the point measured from thecentroid, and s is the arclength value along the boundary.The values obtained are smoothed using a Gaussian with asigma value of approximately 1.7.

3. The boundary is segmented into a number of arcs, theendpoints of which correspond to zero crossings of thesmoothed dr/ds values.

4. Any arcs of less than five pixels in length are mergedwith surrounding arcs.

5. The parameterised equations of the arcs are thenapproximated by fitting to functions quadratic in s using aleast squares method. Each arc is then classified as eitherlinear, concave, or convex by inspection of the equationcoefficients. At this stage any adjacent straight linesegments with similar gradient values are merged. This isnecessary to counteract the tendancy of the segmentationprocess, based on dr/ds values, to break long straightsegments at a point perpendicular to the centroid.

6. Using a least squares method contractivetransformations which match arcs of the same type ontoeach other are calculated. Only transformations withcontractivity factors less than 0.8 are considered to avoidthe value of the (1 -s) -1 factor in the Collage Theorembecoming too large. An error function is calculated for eachtransform generated to test the quality of the match. Theerror function is:

where Sx and Sy are the scale factors of the transform in

the x and y directions respectively, and Ea is a measure of

the overlap between the transform of the shape and theoriginal. All values are normalized to restrict E to the range[0,100].

7. If the best error value obtained for a match to a given arcis less than the set threshold then the transform is acceptedas part of the IFS and written to a file. The matched arc isthen removed from further consideration. If no suitablematch is found then the unmatched arc is halved and thetwo new segments so produced are placed at the back of thesegment queue.

8. The search continues considering each segment in turnuntil the queue is empty.

50

Attractor Rendering

The only difficulty with the implementation of the RandomIteration Algorithm is the choice of probability values. Thisis best overcome as described in [2], if the transforms arerestricted to being affine transformations for which thedeterminant of the transform matrix is equal to the ratio ofthe area or the transformed region to the area of theoriginal. Thus, choosing the probabilities for eachtransform to be in proportion to its determinant will resultin an even distribution of points over the attractor. Inpractice this can give very small values of probability forsome transforms so a minimum threshold is set belowwhich probability values are not allowed to fall. A separateprogram has been developed that reads a file containing anIFS, calculates suitable probabilities for each transform,and produces its attractor at the position, scale, andorientation specified by the user.

By choosing the centroid of a shape as the origin of our co-ordinate system during coding we can guarantee that thepoint (0,0) lies on the attractor. Taking this as our initialpoint for the Random Iteration Algorithm means that allsubsequent points can be plotted without having to wait forthem to converge onto the attractor.

3. PROGRAM PERFORMANCE

The IFS coding of simple shapes contained in binaryimages has been achieved using the programs described inthe previous section. Figure 1 depicts the segmentation ofthe boundary of a simple heart shape based upon theinformation contained in the dr/ds plot. Attempts havebeen made throughout the program development to make itas insensitive to noise as possible, especially in this initialsegmentation stage. The success of this is shown in figure 2which depicts the segmentation of the same heart shapeafter a rotation through 45 degrees resulting in the additionof significant amounts of noise along the boundary. Bycomparision with the previous figure it can be seen that thetwo segmentations are almost identical, having the samenumber and type of boundary segments, but with a slight

IMAGE SEGHENTflTION

a r c - l e n g t h ( s )

IMAGE SEGMENTATION

arc-length (s)

Figure 1. The segmentation of a heart shape in theabsence of noise.

Figure 2. The segmentation of a heart shape in thepresence of noise.

shift in the positions of the segment endpoints. This isdespite the fact that the graph in figure 2 has many morezero crossings than that in figure 1.

The results of the collage construction are shown in figure3. The sequences of collages corresponding to decreasingerror thresholds show a clear convergence to the originalshapes. An effect that becomes apparent at low thresholdsis that the transforms appear to migrate towards theboundary leaving large gaps in the interior of the collage.This is due to the transforms becoming very small in orderto minimise matching error and as a result they do notextend much into the body of the shape. In themselves thegaps in the collage are not a problem since it is only theshape boundary information we are really interested in.

Figure 3 also shows the output from the attractor renderingprogram for each of the collages. Again the determinsticrelationship between the error threshold and the accuracyof the representation is well demonstrated. However, theeffect of leaving gaps in the collage becomes morenoticable because of the recursive structure of the attractorwhich means that gaps get mapped along with eachtransform resulting in a more diffuse coverage of theattractor than could be expected from examination of theoriginal collage. This too should be acceptable because thecollages have no gaps on the boundary and so none shouldappear in the rendering of the attractor. It can be seen infigure 3c that this is not in fact the case since large sectionsof the boundary that are clearly visible in the collage havefailed to be produced during the rendering process. This isbecause the missing regions of the boundary have beenmatched to themselves during collage construction. Thepractical result of this is that a narrow section of thecollage is being constructed from an even narrower section,(a contraction mapping of itself). Upon rendering theattractor becomes vanishingly thin at these points.

Figure 4 shows the results of collage generation for theheart shape at varying thresholds and in the presence ofnoise. As demonstrated the segmentation is quite robust so

51

the differences between these collages and those in figure3a are due almost entirely to the effect of noise on thecalculation of the error measure for each transform. Aswould be expected more transforms are required toproduce a collage of the noisy image. However, the limitingeffect of the resolution of the original image isdemonstrated by the fact that both the noisy and cleanimages require a similar number of transforms when theerror threshold becomes too small.

Finally, the time taken for the IFS codes to be produced

ranged from 60 to 300 seconds depending on the number oftransforms used and the complexity of the shape. Noattempts have been made to optimise the speed of thecoding program but it is certain mat an improvement of anorder of magnitude can be achived with the hardwarecurrently being used. Rendering of the attractor wasachieved at a rate of 1500 pixels per second and thepictures in the figures contain 50000 pixels each. Thespeed of the rendering process is only limited by the speedat which floating point calculations can be done.

F

T H R E S H . . . 8

T R A N S . . 1 2

T H R E S H . . . 2

T R A N S . . 1 4

T H R E S H . . . 1

T R A N S . . 2 4

THRESH.TRAHS.

.64.19

THRKSH.TRANS..

.3221

THRESH.TRANS.

. .8.51

THRESHTRAHS.

. . .2126

(a) (b)

THRESH.

TRANS.

.16.11

THRESH

TRANS.. . .8.12

THRESH.

TRANS.

. .4

.23THRESH.

TRAHS.. .2.35

THRESH.

TRANS..16.11

THRESH

TRANS.

. . .8.12

THRESH.

TRANS.

. .4

.15THRESH.

TRANS.. .2.19

(c) (d)

Figure 3. Collages and their attractors for the coding of various shapes. In each of the figures a-d the picture onthe top row is the original shape. The next row is a sequence of collages and beneath them is a rendering of thecorresponding attractor. The error threshold and the number of transforms used in the construction of the collagesis given beneath each collage-attractor pair.

52

4

THRESHTRANS.

. ..8.13

THRESH.TRANS.

. .4.17

THRESH.TRAHS.

. .2.21

THRESH.TRANS.

. . 1.23

Figure 4. Collages and attractors for codings of anoisy image

4. CONCLUSION

This paper demonstrates that it is practical toautomatically generate IFS representations of two-dimensional shapes to a level of accuracy limited only bythe resolution of the original image. The method has beenassessed in terms of the speed of code generation, accuracyof shape reconstruction and the ability to cope wih noisyimages. The results show that viable applications tomachine vision could be possible provided attention is paidto the following areas:

i. To avoid the appearance of gaps in the shape boundaryupon the generation of the attractor it is necessary to findcollages that completely cover the original shape. There aretwo approaches that can be made towards the solution ofthis problem. Firstly, we can simply expand the currenttechnique and look for transformations that cover theinterior as well as the boundary. Alternatively, we canfollow the example of [3], and add a 'fixed set map' to theIFS -in effect describing a shape as the union of theattractor of the IFS and a fixed region. If the fixed mapcan be expressed as the combination of ellipses or asimilarly simply defined shape then it can be incorporatedinto the IFS in such a way that the Random IterationAlgorithm can still be used. This second method doeshowever detract from the simplicity of the idea of acompletely recursive definition of shape.

ii. As it stands the methods described in this paper arecapable of producing reasonably accurate reconstructionsof a coded shape with possible applications to objectrecognition through template matching using the renderingof the attractor. A more powerful way of using the IFS

codes would be to be able to match shapes in the 'codespace' - by the direct comparison of code coefficients. Inorder to attempt this the values of the transformcoefficients in the IFS must be made invariant with respectto the scale and orientation of the coded shape.

iii. The present search strategy for collage construction isrelatively crude and rather slow. Often the calculated IFScontains one or more 'redundant' transforms in that theyhave been included to match a section of the boundary thathas already been adequately covered by other transformsmatching different sections. Thus, a more sophisticatedsearch strategy could produce more compact codes andmore quickly.

iv. The figures of the previous section show the importanceof setting the correct error threshold. If the threshold is toohigh poor representations are obtained, whilst a too lowsetting results in extended execution times for relativelylittle improvement in the representation. Methods fordetermining the optimum threshold for a given shape arerequired, or else the development of a completelythreshold-independant coding scheme.

Research is currently in progress in all of the above areas.

AcknowledgementsThe authors would like to thank MBrown, J. Anderson,and G.Gapper of the BAe Sowerby Research Centre foruseful discussions. P.Giles and D.Waugh acknowledgeSERC studentship support, and the former is grateful forBAe CASE sponsorship. This work has been madepossible by the generous support of the Durham UniversitySpecial Equipment Fund.

5. REFERENCES

1. Barnsley, M. Fractals Everywhere. AcademicPress (1988).

2. Barnsley, M. Sloan, A.D. "A Better Way toCompress Images" Byte Jan. (1988 ) pp 215-223.

3. Libeskind-Hadas, R. Maragos, P. "Applicationof Iterated Function Systems and Skeletonizationto Synthesis of Fractal Images" SPIE Vol. 845Visual Communications and Image Processing II(1987) pp 276-284.

4. Barnsley, M. Ervin, E. Hardin, D. Lancaster,J. "Solution of an Inverse Problem for Fractalsand Other Sets" Proceedings of the NationalAcademy of Science USA vol.83 Apr. (1985 ) pp1975-1977.

5. Barnsley, M. Demko, S. "Iterated FunctionSystems and the Global Reconstruction ofFractals" Proceedings of the Royal Society ofLondon A399 (1985) pp 243-275.

53

top related