On the Conversion of Filled Polygonal Regions from Raster to Vector Representation

  • Upload
    iw2lsi

  • View
    225

  • Download
    0

Embed Size (px)

Citation preview

  • 8/6/2019 On the Conversion of Filled Polygonal Regions from Raster to Vector Representation

    1/5

    On the Conversion of Filled Polygonal Regions from Raster toVector Representation

    J.R.PARKERDepartment of Computer Science, University of Calgary, 2500 University Drive NW, Calgary, Alberta, Canada T2N-IN4

    The usual method for specifying a fill pattern is to give a small sample of the pattern in raster form. A plotting routinethen repeats this pattern over an arbitrary regio n. It is difficult for devices such as pen plotters to accura tely reproducepictures specified in this manner. By converting the original fill pattern to v ectorform, it is possible to fill arbitrarypolygonal regions with a good app roximation of most raster patterns.

    Received November 1987, revised July 1988

    1. I N T R O D U C T I O NA. il l pattern is an arrangement ofpixels (raster form) orlines (vector form) that will be repeated over some areaor areas of a picture. The purpose is to identify areas thathave some characteristic in common; in the case of amap, regions of similar population, vegetation, climateor altitude may be filled with the same pattern. The useof fill patterns is quite common in mapping and datagraphing applications, where this sort of characterisationsimplifies the interpretation of the picture by the viewer.

    Fill patterns are most often specified as either a singlepixel value,12 as in a simple coloured region, or as a smallraster image that represents a sample of the pattern. Inthe latter case the sample must be large enough to beunique but small enough to eliminate redundancy. Atemplate size of 16 by 16 pixels is not unusual. This smallregion is then plotted repeatedly over a selected picturearea. The pattern should be arranged so that lines thatmeet the boundary of the small fill-pattern template willmeet each other when plotted over a larger area.3 8 Thiscreates the appearance that is expected by the viewer.

    An example of filling with a small template appears inFig. 1. Fig. 1 a shows a map as a simple line drawing. The

    patterns are given as bit maps, represented by a series ofhexadecimal values (b). The map, in this case a map ofthe Province of Alberta, contains a number of polygonalregions each of which is filled with one of the bit-map

    patterns (1 c). This is not an unusual way of specifying afill pattern, nor is it an unusual application. However,the resulting map must be in raster form, and this isdifficult to reproduce on a pen plotter or other vectordevice.

    2. C O N V E R S I O N TO V E C TO R SIf a pen plotter is to be used as an ou tput device, there arethree alternatives. First, the entire picture can beconverted into vector form. This is a time-consumingprocess, even if it can be done accurately. Secondly, theraster fill patterns can be assigned indices, and thesewould be used to indicate a predefined vector-fill patternthat would be used to fill the polygonal area. Theproblem here is matching the raster fill patterns witheach other so that the same raster pattern in two differentlocations results in the same vector pattern being used inboth cases. Another problem is that the raster version of

    o o oo o o o o oo o oo o o o o oo o oo o o o o oo o oo o o o o o

    oo oo oo oo oo o

    o oo oo oo oo oo oo

    o oo oo oo oo oo oo oo oo oo oo oo o

    oo oo oo oo oo o

    o oo oo oo oo oo oo

    o o oo o o o o oo o o o o oo o o o o oo o o o o oo o o o o oo o o o o oo o o o o oo o o

    o o o o o oo o oo o o o o oo o oo o o o o oo o oo o o o o oo o o

    Pattern is encoded as (H ex) :

    1111 , 2 2 2 2 , 4 4 4 4 , 8 8 8 8 , 1111 . . . , 8 8 8 8

    (a) (b) (c)Figure 1. An example of region filling, (a) Map outline; (b) a fill-pattern template; (c) map with filled regions.

    TH E COM PUTER JOU RN AL, VOL. 32, NO . 6, 1989 549

    b y g u e s t onD

    e c em

    b er

    3 ,2

    0 1

    0

    c om

    j nl . ox f or d

    j o ur n

    al s . or g

    D ownl o

    a d e d f r om

    http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/
  • 8/6/2019 On the Conversion of Filled Polygonal Regions from Raster to Vector Representation

    2/5

    J.R.PARKER

    1 . . . 1 . . . 1 . . . 11 . . . 1 . . . 1 . . . 1 .. 1 . . . 1 . . . 1 . . . 1. . 1 . . . 1 . . . 1 . . .

    1 .1 11 11

    1 . . . 1. 1 . 1 .

    1 .1111

    1 . . . 1 . . . 1 . . . 1 . .. 1 . . . 1 . . . 1 . . . 1 .. . 1 . . . 1 . . . 1 . . . 1

    1 1 1 1 1 1 1 1 1. . 1 . .. . 1 . .

    . . . 1 . . . 1 . . . 1 . . . 11 . . . 1 . . . 1 . . . 1 . . .

    . 1 . . . 1 . . . 1 . . . 1 . .. . 1 . . . 1 . . . 1 . . . 1 .

    . . . 1 . . . 1 . . . 1 . . . 11 . . . 1 . . . 1 . . . 1 . . . 1 1

    1 . . . 1 . . . 1 . . . 1 . .. 1 . . . 1 . . . 1 . . . 1 .. . 1 . . . 1 . . . 1 . . . 1

    1 1 1 1 1 1 1. . 1 . .. . 1 . .

    . 1 .1 . 1

    1 1 11 11 1

    1 11 1. 1 . . . 1 .. . 1 1 1 . .

    (a ) (c)

  • 8/6/2019 On the Conversion of Filled Polygonal Regions from Raster to Vector Representation

    3/5

    FROM RASTER TO VECTOR REPRESEN TATION OF FILLED POLYGONAL REG IONS

    The pattern 2a represents a template that contains filledregions within it, which is a special case: the resultingvector fill pattern will contain only the boundaries of thesmaller filled regions. The remaining patterns (2b-d)represent line images and can be reproduced exactly.5 Itshould be noticed that many pixels that belong to morethan one linear feature are re-used, thus keeping thenumber of extracted vectors to as small a number aspossible. Zero length vectors must, however, be retainedfor later use in linking features into polygons.

    The result of applying this method to a raster fill-pattern template is a set of integer coordinates repre-senting the endpoints of the linear features found in thetemplate. These canno t be used directly as a vector fillpattern for a number of reasons. First, the endpoints aregiven as pixel coordinates, whereas they should beexpressed in plots units (inches, centimetres, nibs). Thereis also a problem of alignment; linear features that wereconnected to each other by virtue of the endpoints beingadjacent pixels now have a gap separatingthem. Considerthe following raster image of a rectangle:

    o o o o o o o o o o o o o

    However, when the corresponding vector patterns areused in the same way the result is different:

    o

    o

    o

    o

    o

    o

    o o o o o o o o o

    o o o o o o o o o

    o o o o o o o o o

    o o o o o o o o o

    o

    o

    o

    o

    o

    o

    o o o o o o o o o o o o o

    When converted into vectors, the result might be:

    o o o o o o o o o o o o o

    o o o o o o o o o o o o o

    these vectors can be connected end-to-end to yield aclosed polygon, but cannot reasonably be used as theyare.

    There is a similar alignment problem involving featuresthat connect to the boundaries of the raster template. Inorder that features connect between neighbouring tem-plate regions, the linear features must be extended byone-half of a pixel in both directions. Consider thetemplate seen in Fig. 2b . When two instances of thispattern are copied side by side, they have the followingappearance:

    o o o o o o o o o * o o o * o o o o o o

    o o o o o o * o o o * o o o * o o o * o o o * o o o o o oo o o o o o o o o o o o o o o o o o o o o o o o

    o o o o o o o o o o o o o o o o o o o o o o o oo * o o o * o o o * o o o o o o * o o o * o o o o o o o o

    The gaps between adjacent instances of the pattern canbe eliminated by extending the vectors that intersect thepattern boundary by the distance equivalent to one-halfof a pixel width.

    3. L I N K I N G A N D R E S C A L I N GLinking of the vectors is performed principally to createpolygons from formerly solidly shaded areas (Fig.2a).Linking is done using the endpoints on ly. Starting at thefirst vector, distances between its endpoin ts and all otherendpoints a re computed. If a distance of 2**0.5 o r less isfound, then the two vectors involved are considered to bejoined at the ends. Extension of the polygon continuesfrom the unused end of the new vector, until no adjacentvectors are found. This process is repeated until allvectors have been examined.

    The result is a collection of poly-lines; each poly-linecan be converted into a polygon if the start and endpoints are within 2**0.5 units of each other. These arethen reprocessed into sequences of vectors that can bedrawn individually. The coordinates of the vectorendpoints at this stage are still the integer pixelcoordinates from the original grid.

    The final step is to transform the vector endpointcoordinates on to a new grid, so that vectors willconnect across unit fill-pattern boundaries. Fig. 3illustrates this transformation. The raster image isconsidered to begin at the (1,1) pixel, with pixelsoccurring every unit along both axes. The system used bythe vector image is 0.5 units larger in all directions, andbegins at a (0,0) origin point. Therefore, every vectorthat intersects any of the four boundaries in the original

    system must be extended to meet the boundaries of thenew system. Since we are only concerned with linearfeatures this presents no difficulty. These vectors are nowrescaled to fit a unit square, so that the pattern may beeasily scaled by the filling algorithm.

    The fill-pattern template is at this point represented asa collection of vectors that lie within a unit square. To filla polygonal region with a pattern, a square region ismoved across the polygon in raster-scan fashion with nooverlap between consecutive square regions. Within eachsquare the template vectors are plotted, clipping againstthe polygon bounda ries. The vectors are scaled to fit thedimensions of the square exactly by multiplying allvectors by the width of the square in plot units. The fill

    pattern may in this way be scaled independently of theremainder of the picture.

    TH E COM PUTE R JOU RN AL , VOL. 32, NO . 6, 1989 551

    b y g u e s t onD

    e c em

    b er

    3 ,2

    0 1

    0

    c om

    j nl . ox f or d

    j o ur n

    al s . or g

    D ownl o

    a d e d f r om

    http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/
  • 8/6/2019 On the Conversion of Filled Polygonal Regions from Raster to Vector Representation

    4/5

    D. A. UM PHR ESS, U. W. POOCH AND M. TAN1K

    Vectorcoordinates

    Raster

    coordinates

    1

    3

    2

    1

    oo

    yo

    o

    yoo

    yo

    oo

    oo

    oo(c)

    Figure 3. Raster-to-vector coordinate transformation, (a) Raster and vector coordinates; (A) a line in raster coordinates;(c) an extended line in vector coordinates.

    4. R E S U LT S A N D C O N C L U S I O N S

    Fig. 4 shows an example of a result from the complete fillconversion process. The polygonal areas being filled aresimply the letters of the word 'F IL L ', and the fill

    patterns used are those of Fig. 2; the polygons are clearlynot all convex, a common restriction on vector-clippingprocedures. In all cases the fill patterns were originallyspecified as a 16 by 16 pixel image. The execution timesneeded to convert the fill patterns to vector form areshown in Table 1.

    The times shown in Table 1 are an average taken overten trials on a loaded VAX-11/780. The column labelled'number of vectors' in the above table gives the total

    Table 1.

    Pattern

    Fig. 2 (a)Fig. 2 (b)Fig. 2(c)Fig. 2(rf)

    Fill pattern

    Executiontime (sec)

    0.680.420.370.26

    conversion times

    Number ofvectors

    3378

    19

    Totalconnectivity

    1561148056

    number of linear features extracted from the fill pattern.Total connectivity is computed as the sum ofthe numberof neighbours of each set pixel. The time needed toextract the vectors from a fill pattern appears to be morea function of total connectivity than of the number offeatures found. The time needed to fill a polygonal regionis a function of the number of sides in the polygon, thescale factor applied to the fill pattern, and the number ofvectors in the fill pattern. A comparison of times forfilling would not be relevant.

    It was noted that if the fill pattern contains filled areas(Fig. 1 a) the boundary-enchancement procedure shoulduse only the horizontal and vertical neighbours todetermine which pixels form a boundary. This will resultin the filled regions being outlined, thus preserving theoverall structure, if not density, of the original pattern.Line-image fill patterns should have all eight neighboursconsidered. It was also found that allowing a pixel to beused in more than one vector, a characteristic of thefeature-extraction process, caused redundant features tobe extracted from non-line-image patterns. While thishas no effect on the appearance of the filled regions, itdoes impact the execution time of the filling process.

    The methods described above were devised for thepurpose of converting a large collection of pictures,actually digitised maps, from one device format toanother. This enabled a change of computer system to be

    ox

    ox

    ox

    ox

    X Xo o

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    ox

    Figure 4. Example of vector fil l.

    552 TH E COM PUT ER JO UR NA L, VOL. 32, NO. 6, 1989

    b y g u e s t onD

    e c em

    b er

    3 ,2

    0 1

    0

    c om

    j nl . ox f or d

    j o ur n

    al s . or g

    D ownl o

    a d e d f r om

    http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/
  • 8/6/2019 On the Conversion of Filled Polygonal Regions from Raster to Vector Representation

    5/5

    FROM RASTER TO VECTOR REPRESENTATION OF FILLED POLYGONAL REGIONS

    effected. For this purpose the method works very well.There are other potential applications that are currentlybeing explored; for example, the removal of existing fill

    patterns from raster images, the construction of ortho-photomaps from digitised photos, and digital fontscaling, to name a few.

    R E F E R E N C E Sl . C . Arcelli and A. Massarotti, Regular arcs in digital

    contours. Computer Graphics and Image Processing, 4339-360 (1975).

    2. F. L. Bongiovanni and A. Zorat, The discrete equation ofthe straight line. IEEE Transactions on Computers, C-24,310-313 (1976).

    3. K. E. Brassel and R. Fegeas, An algorithm for shading ofregions on vector display devices. Proc. SIGGRAPH 79 , p.126-133; Computer Graphics, 13 (2), 126-133 (1979).

    4. I. Chakravarty, A single pass chain generating algorithmfor region boundaries. Computer Graphics and ImageProcessing, 15, 182-193. (1981).

    5. H. Freeman, Computer processing of line drawing images.Computing Surveys, 6 (1), 57-97 (1974).

    6. S. H. Y. Hung, On the straightness of digital arcs. IEEETransactions on Pattern Analysis and Machine Intelligence,PAM1-7 (2), 203-215 (1985).

    7. C. E. Kim, On cellular straight line segments. ComputerGraphics and Image Processing, 18, 369-381 (1982).

    8. D. T. Lee, Shading of regions on vector display devices.Computer Graphics, 15, (3), 37-44 (1981).

    9. W. H. H. J. Lunscher and M. P. Beddoes, Fast binaryimage boundary extraction. Computer Vision, Graphics,and Image Processing, 38, 229-257 (1987).

    10. R. Navatia and K. R. Babu, Linear feature extraction anddescription. Computer Graphics and Image Processing, 13(3) (1980).

    11 J. R. Parker, Extracting vectors from raster images.Com-puters and Graphics 12 (1) (1988).

    12. T. Pavlidis, Contour filling in raster graphics, ComputerGraphics, 15 (3), 29-36 (1981).

    13. S. Pham, Digital straight segments. Computer Vision,Graphics, and Image Processing, 36, 10-30 (1986).

    14. A. Rosenfeld, Digital Straight Line Segments.IEEE Trans-actions on Computers C-23 (12) 1264-1269 (1974).

    Announcement24-26 SEPTEMBER 1990

    IFIP WG8.4 Conference on Multi-UserInterfaces and Applications, Heraklion, Crete,Greece

    Organized by IFIP Working Group 8.4, incooperation with ACM SIGOIS, Greek Com-puter Society

    Call for papers

    Computer-supported cooperative work

    (CSCW) and othe r multi-user applications arebroadly concerned with the combined use ofcommunications and computer technology bya group of people. The Conferenceon Multi-User Interfaces and Applications will focus onuser interface and architectural issues forCSCW and 'groupware' systems. The con-ference welcomes papers describing the design,implementation and evaluation of systemsthat encourage collaborationor coordinationamong users. Descriptions are solicited ofunderlying technologies(e.g. shared-windowsystems, wide-area file systems, multimedianetworks), example applications (e.g. co-

    authoring systems, group decision support)and related research topics (e.g. multi-userinterface design, novel concurrency controlschemes).

    WG8.4 has previously organiseda numberof conferences and workshops: 'OfficeSystems' (Helsinki, 1985), 'Methods andTools for Office Systems' (Pisa, 1986), 'OfficeKnowledge: Representation, managementand utilization' (Toronto, 1987), 'OfficeIn-formation System s: The design proc ess' (Linz,1988) and 'Groupware Technology' (PaloAlto, 1989). The Conference on Multi-UserInterfaces and Applicationsis the sixth eventin this series.

    Suggested topics

    A partial list of topics includes: desktop conferencing co-authoring systems coordination systems electronic meeting rooms group decision support distributed group problem solving design principles for multi-user interfaces multi-user interface management

    shared hypertext/m ultimedia shared-window systems wide-area file systems

    Conference Committee

    General Chair Alex Verrijn-Stuart, Univer-sity of Leiden, Netherlands

    Programme Chair Simon Gibbs, Universityof Geneva, Sw itzerland

    Organising Chair Panos Constantopoulos,FORTH, Greece

    Information for AuthorsSubmit five copies of a double-spaced paper(twenty pages maximum),or electronicsub-mission of equivalent lengthto :Dr Simon Gibbs, Centre Universitaired'Informatique, 12 ruedu Lac, Geneva1207,Switzerland. Te l.: 41 (22) 787.65.87. In terne t:[email protected], uucp: mcvax!cernvax! cui! simon.

    Submission deadline: 20 February 1990;notification of aut ho rs:20 April 1990; camera-ready copy: 1 June 1990.

    THE COMPUTER JOURNAL, VOL.32, NO. 6, 1989 553

    b y g u e s t onD

    e c em

    b er

    3 ,2

    0 1

    0

    c om

    j nl . ox f or d

    j o ur n

    al s . or g

    D ownl o

    a d e d f r om

    http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/http://comjnl.oxfordjournals.org/