The trapezoidal approximation of digitized images

The trapezoidal approximation of digitized images

COMPUTER VISION, GRAPHICS, AND IMAGE PROCESSING 27, 64-77 (1984) The Trapezoidal Approximation of Digitized Images CHARLESM.WILLIAMS Informatio...

2MB Sizes 2 Downloads 108 Views

COMPUTER

VISION,

GRAPHICS,

AND

IMAGE

PROCESSING

27, 64-77 (1984)

The Trapezoidal Approximation of Digitized Images CHARLESM.WILLIAMS Information

Systems

Department,

Georgia

State

University,

Atlanta,

Georgia

30303

Received January 31,1983; accepted May 23,1983 A highly efficient process for representing and compressing scanned data is described which vectorizes black-white document symbology by approximating it by means of trapezoidal shapes. Also discussed are methods for encoding the resultant descriptions for transmission or archival storage. Test results indicate the system can be used for the real-time compression of facsimile data, and measurements obtained from CCITI test documents reveal performance improvements over the Japanese READ code of 1.3 for business documents and 1.7 for technically oriented material.

INTRODUCTION

The digital compression of scanned data can be performed by identifying and efficiently encoding the numeric and geometric redundancies found in the pictorial information derived from scanning digitizers. If the compression scheme is information preserving and thereby creates an output which exactly reproduces the original digitized image, it may be compared to the mathematical process of curve fitting. On the other hand, if it alters the original, it is analogous to curve approximation. This paper is concerned with the latter-the compression of scanned images by means of geometrically based approximations.

THE IMAGE

REPRESENTATION

SYSTEM

The image representation process which produced all of the accompanying figures is accomplished in several stages. Data obtained from digitizing the original documents are first converted into run-length encoded values designating the coordinates of black-white transitions along each scan line. These are then collected into pictorial segments representing two-dimensional contiguous black areas, and the peripheries are approximated by means of straight line segments to yield trapezoidal descriptions of the originals. Pictorial noise is removed next, and the trapezoids are encoded, transmitted, and reconverted into picture element form to reconstitute the document images on output recorders.

BOUNDED

PRECISION

The bounded precision approximation trapezoidal descriptions is unique in that principles. It operates on the assumption accurate to be displayed in its original form. fidelity the algorithm must derive analytic distances of each of the original data points. 64 0734-189X/84

$3.00

Copyright 0 1984 by Academic Press, Inc. All rights of reproduction in any form reserved.

APPROXIMATIONS

process [l, 21 used for forming the it is based entirely upon geometric that the source data are sufficiently Accordingly, in order to preserve visual curves which pass within prescribed The author derived this technique after

TRAPEZOIDAL

APPROXIMATION

OF IMAGES

65

he had discovered that the classical least-squares [3-61, Chebycheff [7, 81, and nonlinear approximation procedures [9, lo] were not appropriate for the task. Both least-squares and Chebycheff methods assume that the form of the underlying function is known and as a consequence fail to detect and faithfully represent the angular patterns which typify the characteristic components of black-white documents. The former method deals with the attributes of aggregate data rather than with those of individual points. It was designed for the express purpose of minimizing the variance of a curve passing through statistically associated values, and is incapable of tracking the data when the type of association changes abruptly. The Chebycheff procedure on the other hand minimizes the maximum deviations directly, but performs as poorly as least squares in detecting slope discontinuities. Both methods, however, can be adopted to treat such data by comparing the deviations of the original points from the derived curve and repeatedly subdividing the interval of approximation until the desired precision of fit is obtained. Unfortunately, this process has disagreeable consequences in that processing times are potentially proportional to the square of the data volume, and all points must be retained in computer memory for each stage of the process. More sophisticated nonlinear approximation procedures can also be applied but they tend to be computationally complex and require exorbitant amounts of both computer time and memory. The bounded precision approximation techniques handle these problems directly as they operate upon the individual maximum allowable deviations themselves. Piecewise-linear approximations of data are obtained in serial fashion provided the data are fed to the algorithm in a time-series format. Computer times are short and can be made linearly proportional to the number of data points processed. Computer memory requirements are also modest and are independent of the data volume.

TRAPEZOIDAL

ENCODING

The output from the approximation process is sequences of line segments describing the boundaries of the black areas on the document. These line sequences are converted into sequences of trapezoidal component shapes whose bases are aligned with the scan and replot axes [ll]. A simple encoding of such a trapezoid is a sextuplet ( Xjj, Y,,, ej, AXij, Aqj, AT,) with: Cxij3

(Tj

Tj)

+ AXj, ylj + Aqj)

tyj + Awj

Coordinates of the upper left comer of trapezoid i Width of the upper base Coordinates of the lower left comer of trapezoid i Width of the lower base.

A major reduction in entropy can be achieved by taking advantage of the fact that vertically contiguous black areas will have common interior trapezoidal baselines which can be removed by chain encoding their descriptions. Thus the contiguous

CHARLES

66

M.

WILLIAMS

trapezoid sextuples for black area i (Xij, yj, yj, (X,, + AXij,&j

AX,,, Aqj, Ayj) + “qj,yj

+ A~j,AXi,j+l,AYl,j+,,A~,,+,)

(X,j + AX;, + AXi,,j+l, yl.j + AYj + AY,.j+t, Fj + Ay:, +A~,,+,,A~,j+2,A~~j+z,A~,j+*)

can be reduced to a chain encoded sequence of triples:

Incremental descriptions ACij for chain ij

jEoc

End of Chain.

Moreover, if documents have black areas with leading edges roughly parallel to the scan axis they will have duplicate values for their initial abscissas Xii. This redundancy can be exploited by sorting the trapezoidal chains into ascending order of initial abscissas so that those with common values are grouped together. The resultant trapezoidal descriptions of a document then become Trapezoid chain origin (X,,, Y,) Chain origin (X0, Yoo + AY,,) Chain origin (X0, Y, + AY,, + AY,,) End of Line Chains origin X0 + AX,

Chains origin X0 + AX, + AX, EOL EOD

End of Document.

It should be noted that, provided the chains on each line are arranged in ascending sequence by yij values, all AX, and ATj values will be positive and the data will be transmitted and presented to raster display devices in a top-to-bottom, left-to-right fashion.

TRAPEZOIDAL

APPROXIMATION

67

OF IMAGES

Noise removal is easily accomplished by deleting trapezoids whose AX;, dimension is less than a prescribed limit. It is suggested that final encoding then be accomplished by means of modified Huffman methods [12]. TEST RESULTS

Table 1 gives the entropy values obtained by applying this process to the eight CCITT test documents shown in Figs. 1, 2. (All figures in this document were produced on a Versatec 1200 A raster plotter at 200 pixels/in. after processing the run-length encoded data on a Univac 90/80 digital computer. The original documents were scanned at 7.7 pixels per linear millimeter.) The values listed in Table 1 include estimates for the entropy of end-of-chain (EOC) and end-of-line (EOL) codes but no allowance has been made for data transmission redundancy and synchronization bits. Noise removal was accomplished by discarding trapezoids whose AXij magnitudes were less than 1 pixel. The corresponding reduction in entropy was approximately 10% of the total. This compression performance is essentially identical to the Japanese facsimile READ code [13] for an error tolerance of 0.5 pixel. The average improvement factors for a tolerance value of 1 pixel, however, are 1.3 for business documents and 1.7 for technically oriented material. In addition, the format of the data facilitates the computer graphic manipulations evidenced by Figs. 4-7. The scaled-up replots of CCITI Document 1 in Figs. 4-7 show how the visual quality of the results depends upon the value of the bounded precision approximation error tolerance. It should be noted that a tolerance value 0 will result in an exact duplication of the original data shown in Fig. 3. A value of 0.5 pixel is probably optimal for producing the best visual results as it tends to smooth out digitizing edge noise. A considerable reduction in entropy, however, is realized if a tolerance value of 1.0 pixel is used, and the readability of the results is not markedly affected. It is interesting to note that readable copy in Fig. 6 is obtained even for tolerance values

TABLE 1 Document Compression Statistics Tolerance 0.5 CCIrldocument

Business Technical Total

Trapezoids

Entropy (bits)

Tolerance 1 .O

Compression factor

Trapezoids

Entropy (bits) 112,348

Compression factor

11,229 4,665 15,633 42,290 18,473 7.131 38,254 8,936

151,273 74,931 229,891 566,725 261,428 112,868 578,637 123,795

27.14 54.79 17.86 7.24 15.71 36.38 7.10 33.17

6,273 2,169 8,950 24,220 10,020 3,519 25,072 4.084

172,786 424,400 191,968 75,657 462,000 81,871

36.54 85.77 23.76 9.67 21.39 54.21 8.89 50.15

125,879 20,732 146,611

1,787,954 311,594 2,099,548

11.48 39.53 15.64

14,535 9,772 84,307

1,363,502 205,397 1,568,899

15.06 59.97 20.94

41,869

Document

1 FIG.

1. CCI’M test documents.

Document

2

22-7-71

iii

loon

3s

Pk44 a+Jr . . r swi&J-u

12a

TRAPEZOIDAL

APPROXIMATION

Al

OF

IMAGES

69

70

CHARLES

M.

WILLIAMS

TRAPEZOIDAL

APPROXIMATION

OF IMAGES

71

72

CHARLES Dsu

M. WILLIAMS

Pete,

Permit trennission.

m

to

introduce

you

to the

facility

of

facsimile

In feceimile a photocell is caused to perform a raster The variations of print density on the da the rrrbject copy. ceuee the photocell to generate an analogous electrical vidl lbio ai-1 ia used to modulate a carrier, which is transmi -to daatinatioa over a radio or cable commications linl At the remte terminal, demodulation reconstructs signal, which is used to modulate the density of print printing device. Thi5 device is scanning in a raster As a result, vitb ehtt st the trmmiietin:: ten&al. copy of the subject docuent is pro&iced. Probably

you

UNC

have

for

this

facility

in your

the 1 prodi scan : a fat: organ

::sur; sincerely,

Y.J. MOSS Crow;:, Le:dm

FIG. 3. CCI’ITl.

- Facsimi

Original data.

as high as 4.0 pixels. While the integrity of individual characters is adversely affected in this case, context permits the total message to be read without loss of information. Figure 7 is a scaled-up replot of the trapezoids used in forming part of Fig. 4. It proves that art may even be found in business letters-or is it perhaps beauty in mathematics? Figure 8 is further supporting evidence for the claim that the trapezoidal system is especially appropriate for representing technical images. This Deer Pete, Permit m trardmdcm. In faceidle

co introduce

you

to

the

facility

of

facsimila

e photocell ir caused to perform a raster lb veriatima of print density on the d* WC tb photocell to generate an analogous electrical vidl Tbie l iw1 ie rued to adulate a carrier, which L transmi remtedutimtiot~overe radio or cable commm ications 1%

the l bject

copy.

At tlbe remte terdnal, dcvrduletion reconstructs uhicb ie wed to modulate the density of print printing dwiee. %hie device is seaming in a rwter vitb that et the treeemitting termhal. A3 a result. w of the l sbject &c-t is produced. em,

Robebly

you

hew

uee*

for

this

facility Yours

in

your

the 1 prod1 scan : a faci organ

sincerely,

P.J. CROSS Croup Leader

- Facsimi

FIG. 4. CCITT’l: tolerance, 0.5 pixel; compression, 27.14

TRAPEZOIDAL

APPROXIMATION

73

OF IMAGES

our Pete, ?er& trurdmdm. In

I

you

KO intraduce

facility

the

of

faceftil~

photocell is caused to perform a ra8Ctr Tt~hc frictions of print density on the 6 the photocell to gewrate am analogous eLectrica vidl d-1 ia wed to rrdulatc a cm&r, which is crnnd icatiooo linl dutinatiom over a radio or cable c-

the l bjrt wwm lbim mtm

At

l ivl,

faceidle

to

u*y.

the

mto

uhich

prloting

ir

dwiw.

With

tk8t

copy

of

8t the

Robably

the

l uhjmzt you

l

terminal, demdulation reconstructs uScd to modulate the density of print

lhir &vice trawmittieg is

docent

have

is scanning tc4n81.

curs

for

in a raster As a rceult.

this

facility

in your

FIG. 5. CCITTl:

- Facsimi

1.0 pixels 36.54

tolerance, 1.0 pixel; compression, 36.54.

?.S. mass 6wuplasdwcc1lT1 TOleG3llCe Compression

FIG.

6. CCITTl:

organ

sincerely,

P.J. CROSS Croup Leader

-

scm I a facl

produced.

Yours

cclTT1 TOlelWlClfe Compression

the prudr

Fwiii

4.0 pixels 41.42

tolerance, 4.0 pixels; compression, 41.42.

74

CHARLES

M. WILLIAMS

enlargement of a compressed nautical map is virtually indistinguishable original but has been compacted by a factor of 109. COMPUTER

PROCESSING

from the

TIMES

The computer times listed in Table 2 for processing the CCITT test documents were obtained on a Univac 90/80 using FORTRAN IV. They have been categorized according to system function and the type of document processed. Documents 1, 3, 4, 5, and 7 are considered business related and are dominated by short-stroked text. Documents 2, 6, and 8 are more technical in nature and are typified by fewer and longer stroked graphical objects. The summary of times required for processing 1000 runs given in Table 3 is validation of the claim that computer times are directly proportional to the number of runs on a document. It should be noted that these values are dominated by input/output (I/O) conversion costs, approximately half of which is an artifact of the fact that the test data exist in an alphanumeric form which must be converted to binary for internal processing. DISCUSSION

The system can be made considerably more efficient by implementing it by means of computer hardware components operating in parallel. The trapezoidal approximation procedure, for example, is ideally suited for a multiprocessing environment, and its time requirements may be reduced to become comparable to those of pictorial segment collection. If input/output activities are performed concurrently with these two, it is estimated that the system can process scanned data at rates greater than

ccIlT1 Trapcmids Toterams OS pixel*

FIG. 7. CCITTl: trapezoids: tolerance, 0.5 pixel.

TRAPEZOIDAL

APPROXIMATION

OF IMAGES

15

2000 runs per second on computers whose operating speeds are comparable to the Univac 90/80. Significant reductions in entropy can also probably be realized by approximating some of the pictorial data by means of parallelograms, rather than trapezoids aligned with the scan axis. This should have the effect of considerably simplifying the geometric descriptions in light of the fact that engineering drawings and much other lettering work, such as typescript, are formed for the most part from line strokes of constant breadth. Such curves can probably be derived by altering the measurement geometry used in the current bounded precision approximation algorithms. Further reduction in entropy can also be obtained by slightly rotating the trapezoidal base axis so that it is aligned with the text on the document rather than

SECTION Chart 51341 [Plan E)

FIGURE 8

I

76

CHARLES

M. WILLIAMS

TABLE 2 Computer Processing Times (seconds)

Business Technical Total

Trapezoidal approximation

Runs 48,183 28,131 81,545 181,990 93,329 53,907 163,063 49,836

72.8 26.4 97.7 273.8 114.5 40.6 279.4 46.7

23.9 11.7 43.5 88.8 46.8 25.4 88.4 22.6

54.9 29.3 99.6 202.8 116.2 55.7 181.3 57.6

151.6 67.4 240.8 565.4 271.5 121.7 549.1 126.9

568,110 131,874 699,984

838.2 113.7 951.9

291.4 59.7 351.1

654.8 142.6 797.4

1784.4 316.0 2100.4

Document 1 2 3 4 5 6 I 8

Pictorial segment collection

I/O conversion

Total

TABLE 3 Computer Processing Time (set) for 1000 Runs

Business Technical Total

I/O conversion

Pictorial segment collection

1.48 0.86 1.36

0.51 0.45 0.50

Trapezoidal approximation

Total

1.15 1.08 1.14

3.14 2.39 3.00

with the scan axis [14]. This type of data manipulation should be reasonably straightforward as measurements of line stroke directions will already have been obtained during the approximation phases of the process. Finally, the trapezoidal representation of images is especially appropriate when their presentation on raster display devices is to be made under affine transformations which scale, translate, or skew the image parallel to the trapezoidal base axis. These operations will alter the dimension, but not the top-to-bottom, left-to-right sequence of the trapezoids as they are passed to the display device. ACKNOWLEDGMENTS

This work was supported in part by a research grant from the Research Program Committee, College of Business Administration, Georgia State University. Thanks are also extended to Mr. Dennis Bodson of the National Communications System for furnishing the CCITT document data used throughout the paper. 1. C. M. Williams, An efficient algorithm Computer

Graphics

and Image

REFERENCES for the piecewise linear approximation

Processing

8, 1918,

2. C. M. Williams, The bounded precision approximation Graphics and Image Processing 16, 1981, 370-381.

of planar curves,

286-293.

of planar curves by straight lines, Computer

TRAPEZOIDAL

APPROXIMATION

77

OF IMAGES

3. H. Stone, Approximations of curves by line segments, Math. Comp. 15, 1961,40-47. 4. B. Glass, A line segment curve-fitting algorithm related to optimal encoding of information, and Control

Irtjorm.

5, 1962, 261-267.

5. A. Cantoni, Optimal curve-fitting with piecewise linear functions, IEEE

Trans.

Comput.

C-20,

1971,

59-67.

D. Conte and C. de Boor, Elementary Numerical Analysis, pp. 191-273, McGraw-Hill, New York, 1972. J. R. Rice, The Approximation of Functions, Vol. 1, Addison-Wesley, Reading, Mass., 1964. F. Scheid, The under-over-under theorem, Amer. Math. Monthly 68, 1961, 862-871. H. Freeman and J. M. Glass, On quantization of line-drawing data, IEEE Trans. systems Sci., Cyhernet. SSC-5, 1969, 70-79. U. Montanari, A note on minimal length polygonal approximation to a digitized contour, Commun.

6. S. 7.

8. 9. 10.

ACM

13, 1970, 41-47.

11. K. Ramachandran, Coding method for vector representation of engineering drawings, Proc. IEEE 68, 1980, 813-817. 12. R. Hunter and A. H. Robinson, International digital facsimile coding standards, Proc. IEEE 68. 1980, 854-867. 13. Y. Yasuda, Overview of digital facsimile coding techniques in Japan, Proc. IEEE 68,1980, 830-845. 14. W. K. Pratt, P. J. Capitant, W. Chen, E. R. Hamilton, and R. H. Wallis, Combined symbol matching facsimile data compression system, Proc. IEEE 68, 1980, 786-796.