Contour Encoded Compression and Transmission
Total Page:16
File Type:pdf, Size:1020Kb
Brigham Young University BYU ScholarsArchive Theses and Dissertations 2006-11-29 Contour Encoded Compression and Transmission Christopher B. Nelson Brigham Young University - Provo Follow this and additional works at: https://scholarsarchive.byu.edu/etd Part of the Computer Sciences Commons BYU ScholarsArchive Citation Nelson, Christopher B., "Contour Encoded Compression and Transmission" (2006). Theses and Dissertations. 1096. https://scholarsarchive.byu.edu/etd/1096 This Thesis is brought to you for free and open access by BYU ScholarsArchive. It has been accepted for inclusion in Theses and Dissertations by an authorized administrator of BYU ScholarsArchive. For more information, please contact [email protected], [email protected]. CONTOUR ENCODED COMPRESSION AND TRANSMISSION by Christopher Nelson A thesis submitted to the faculty of Brigham Young University In partial fulfillment of the requirements for the degree of Master of Science Department of Computer Science Brigham Young University December 2006 Copyright © 2006 Christopher B. Nelson All Rights Reserved BRIGHAM YOUNG UNIVERSITY GRADUATE COMMITTEE APPROVAL of a thesis submitted by Christopher B. Nelson This thesis has been read by each member of the following graduate committee and by majority vote has been found to be satisfactory. _____________________ _____________________________________ Date William Barrett, Chair _____________________ _____________________________________ Date Thomas Sederberg _____________________ _____________________________________ Date Eric Mercer BRIGHAM YOUNG UNIVERSITY As chair of the candidate’s graduate committee, I have read the thesis of Christopher B. Nelson in its final form and have found that (1) its format, citations and bibliographical style are consistent and acceptable and fulfill university and department style requirements; (2) its illustrative materials including figures, tables and charts are in place; and (3) the final manuscript is satisfactory to the graduate committee and is ready for submission to the university library. _____________________________________ _____________________ William A. Barrett Date Committee Chairman Accepted for the Department _____________________________________ Parris K. Egbert Graduate Coordinator Accepted for the College _____________________________________ Thomas W. Sederberg Associate Dean, College of Physical and Mathematical Sciences ABSTRACT CONTOUR ENCODED COMPRESSION AND TRANSMISSION Christopher B. Nelson Department of Computer Science Master of Science As the need for digital libraries, especially genealogical libraries, continues to rise, the need for efficient document image compression is becoming more and more apparent. In addition, because many digital library users access them from dial-up Internet connections, efficient strategies for compression and progressive transmission become essential to facilitate browsing operations. To meet this need, we developed a novel method for representing document images in a parametric form. Like other “hybrid” image compression operations, the Contour Encoded Compression and Transmission (CECAT) system first divides images into foreground and background layers. The emphasis of this Thesis revolves around improving the compression of the bitonal foreground layer. The parametric vectorization approach put forth by the CECAT system compares favorably to current approaches to document image compression. Because many documents, specifically handwritten genealogical documents, contain a wide variety of shapes, fitting Bezier curves to connected component contours can provide better compression than current glyph library or other codebook compression methods. In addition to better compression, the CECAT system divides the image into layers and tiles that can be used as a progressive transmission strategy to support browsing operations. ACKNOWLEDGMENTS I would like to thank my advisor, Dr. William A. Barrett and the other members of my committee who have been patient with me throughout the past few years as this Thesis was drafted and provided aid when needed. I would also like to thank Michael Smith for allowing me the use of his code and getting this research topic started. I would also like to thank my wife Lydia for all her support and encouragement throughout this process. Contents 1 Introduction 1 1.1 Motivation . 1 1.2 Solution: Contour Encoded Compression and Transmission . 3 2 Background 5 2.1 Document Image Compression . 5 2.1.1 Transform Encoding . 6 2.1.2 Context Encoding . 7 2.1.3 Dictionary Encoding . 8 2.1.4 Hybrid Encoding . 9 2.2 Bitonal Compression Strategies . 11 2.2.1 Pattern Matching . 11 2.2.2 Vectorization . 12 2.3 Progressive Image Transmission . 13 2.4 The CECAT Approach . 14 3 Contour Encoded Compression 17 3.1 Binarization of Document Images . 17 3.1.1 Color to Grayscale . 18 3.1.2 Grayscale to Bitonal . 18 3.2 Contour Detection and Rendering . 19 3.2.1 Layered Contour Detection . 19 3.2.2 Contour Filling Algorithm . 22 3.3 Fitting Parametric Curves to Contours . 26 3.3.1 Bezier Curves . 27 3.3.2 Using First Degree Curves (Lines) . 28 3.3.3 Using Second Degree Curves (Quadratics) . 38 3.3.4 Combining First and Second Degree Curves . 40 4 Encoding and Transmission of CECAT Images 45 4.1 Localization of Contours . 45 4.1.1 Storing Contours as Layers . 46 4.1.2 Tiling the Images . 46 4.2 CECAT File Format . 48 4.2.1 Encoded Contour Layer . 48 4.2.2 Residual Image Data Layer . 50 4.2.3 Background Image Data Layer . 51 4.3 Curve Segment Library . 52 vii 4.4 Progressive Transmission . 53 4.4.1 Sample Server Implementation . 53 4.4.2 Rendering the Contour Encoded Tiles . 55 4.4.3 Adding Residual and Background Layers . 55 5 Compression Efficiency and Results 59 5.1 Analysis of CECAT Bitonal Compression . 59 5.1.1 Getting the Settings for the CECAT System . 60 5.1.2 Bitonal Image Compression Results . 64 5.2 Analysis of CECAT Grayscale Compression . 72 5.3 “Hybrid” Image Layer Comparison . 75 5.4 Limitations of the CECAT System . 77 6 Conclusion and Future Work 81 6.1 Conclusion . 81 6.2 Future Work . 82 A Image Datasets 87 A.1 George Washington Papers . 87 A.2 James Madison Papers . 88 A.3 US 1870 Census (200 dpi) . 89 A.4 US 1870 Census (300 dpi) . 90 B User's Guide 93 B.1 Compression Interface . 93 B.2 CECAT Image Viewer . 96 C CECAT Code Base 101 D Bibliography 141 viii List of Tables 3.1 File Size Price for Fixed Borders . 32 3.2 Amount of Beziers Used During CECAT Compression . 42 4.1 Average CECAT Tile Size . 47 4.2 Curve Segment Library Compression Enhancements . 52 5.1 Relative CECAT File Size at Different Error Tolerance Settings . 60 5.2 CECAT Compression file sizes with various “despeckling” settings . 64 5.3 Bitonal compression comparisons for the George Washington Papers . 66 5.4 Bitonal compression comparisons for the James Madison Papers . 68 5.5 Bitonal compression comparisons for 200 dpi US 1870 Census . 70 5.6 Bitonal compression comparisons for 300 dpi US 1870 Census . 72 5.7 Compression comparisons for the George Washington Papers . 74 5.8 Compression comparisons for the James Madison Papers . 74 5.9 Compression comparisons for 200 dpi US 1870 Census . 74 5.10 Compression comparisons for 300 dpi US 1870 Census . 74 5.11 Comparison of “Hybrid” image layers for the George Washington Papers 78 5.12 Comparison of “Hybrid” image layers for the James Madison Papers . 78 5.13 Comparison of “Hybrid” image layers for 200 dpi US 1870 Census . 78 5.14 Comparison of “Hybrid” image layers for 300 dpi US 1870 Census . 78 ix x List of Figures 1.1 Sample Document Images . 2 2.1 200 DPI Image of 1870 U.S. Census . 6 2.2 JPEG Compression Artifacting . 7 2.3 JBIG Encoded Image Slice . 8 2.4 Image Layers created from JPEG Source Image . 10 3.1 Contour Example . 20 3.2 Contour Detection Example . 21 3.3 Contour Layers for Sample Image . 23 3.4 Challenges for Contour Filling . 24 3.5 Contour Filling Algorithm Example . 26 3.6 Suboptimal “Greedy” Algorithm Example . 29 3.7 Segment Contour Mapping Example . 30 3.8 Detected Border Edges . 32 3.9 First Candidate Line Segment . 34 3.10 Comparison of Deltas between Candidate Line and its Associated Contour 36 3.11 Determining the Best Line Mapping . 38 4.1 Tiled Document Image . 47 4.2 CECAT File Structure . 50 4.3 CECAT Tiles . 51 4.4 First 11 Entries in Curve Segment Library . 53 5.1 CECAT File Size verses Error Tolerance . 61 5.2 Compressed Image Quality verses Amount of Error Tolerance . 62 5.3 CECAT Compression for the George Washington Papers . 63 5.4 CECAT Compression for the James Madison Papers . 63 5.5 CECAT Compression for 200 dpi U.S 1870 Census . 63 5.6 CECAT Compression for 300 dpi U.S 1870 Census . 63 5.7 Bitonal image compression for the George Washington Papers . 65 5.8 Bitonal image compression for the James Madison Papers . 67 5.9 Bitonal image compression for 200 dpi U.S 1870 Census . 69 5.10 Bitonal image compression for 300 dpi U.S 1870 Census . 71 5.11 Grayscale image compression for 200 1870 US Census . 73 5.12 “Hybrid” image compression for the George Washington Papers . 76 5.13 “Hybrid” image compression for 300 dpi U.S 1870 Census . 77 xi Chapter 1 Introduction 1.1 Motivation Ten years ago, when someone wanted to learn about a particular subject, they would typically travel to the local library or archive to find an appropriate book or periodical. With the advent of the Internet, however, this process has changed dramatically. In addition to the wealth of information that is growing daily on websites throughout the expanse of cyberspace, many books, newspapers, and periodicals have been scanned, indexed, and placed online to create “digital libraries” [1]. Now people can just log onto the Internet and go to one of these libraries to read through texts stored thousands of miles away. Even rare “special collection” documents become more valuable as the number of people with access to them increases [2].