home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1996 / ARCHIVE_96.iso / discs / utilities / utility_02 / convrters2 / !ChangeFSI / btpc / README < prev    next >
Text File  |  1996-03-11  |  16KB  |  378 lines

  1. Binary Tree Predictive Coding (BTPC), Version 3
  2. ===============================================
  3.  
  4. Contents
  5. ========
  6.  
  7.         What is BTPC?                   Overview
  8.         What's new in Version 3
  9.         Where to find it                Net addresses for code and docs
  10.         Programs                        Details of available code
  11.         Comparisons between BTPC,       Representative results
  12.          JPEG and the state of the art
  13.         Comments on the results         Why and when to use BTPC
  14.         Patents and copyright           No patents, free use.
  15.  
  16. What is BTPC?
  17. =============
  18.  
  19. BTPC is a general-purpose image coding method for lossless or lossy compression
  20. of photographs and graphics. It is well suited for coding multimedia images
  21. which combine text, graphics and photographs, and  is also appropriate as a
  22. general-purpose method when the image type is not known in advance.
  23.  
  24. As a lossy compressor, BTPC is slightly superior to JPEG for photographic
  25. images and much superior for graphics. Visually-transparent coding of color
  26. graphics is usually possible at the rate used by GIF. Against a
  27. state-of-the-art lossy scheme (Said and Pearlman's modified zerotree coder), it
  28. is inferior for photographs but superior for graphics, mixed  and multimedia
  29. images. Moreover (see below), BTPC is much faster.
  30.  
  31. When applied losslessly, BTPC has good performance on both natural images and
  32. graphics. Against a state-of-the-art lossless scheme (Wu's CALIC), it is
  33. usually inferior for photographs and about the same for graphics. Again, BTPC
  34. is much faster.
  35.  
  36. BTPC uses a binary pyramid, predictive coding and Huffman coding. No part of it
  37. is covered by patents. C++ source code is available and may be freely used.
  38. BTPC is inherently progressive, and a straightforward modification of the
  39. decoder to write directly to an on-screen picture buffer allows simple,
  40. progressive, image recovery.
  41.  
  42. What's new in Version 3 - Fast decoding
  43. =======================================
  44.  
  45. In version 3, BTPC decode times have been halved over the previous version
  46. (2c). Version 3 also improves encoding speed and gives slightly better
  47. compression.
  48.  
  49. BTPC decoding speed is now equal to that of the Independent JPEG group (IJG)
  50. JPEG decoder, and more than three times faster than its other rivals. Of
  51. course, in the words of the IJG, it is "still not as fast as we'd like".
  52.  
  53. Where to find it
  54. ================
  55.  
  56. Documentation of Binary Tree Predictive Coding is at:
  57.  
  58. http://monet.uwaterloo.ca/~john/btpc.html
  59.  
  60. Source code is at:
  61.  
  62. ftp://monet.uwaterloo.ca/pub/john/btpcv3.tar.Z
  63.  
  64. To run
  65. -------
  66.  
  67.         cbtpc input_pic output_file [quality]
  68.         dbtpc input_file output_pic
  69.  
  70. The optional quality parameter is a number between 0 and 100. Default is 75.
  71. Quality values roughly approximate JPEG quality values, but 100 is lossless.
  72.  
  73. This version only reads and writes PGM and PPM raw format files (magic number
  74. "P5" or "P6").
  75.  
  76. Comparisons between BTPC, JPEG and the State of the Art
  77. =======================================================
  78.  
  79. I have compared BTPC with the current standard, JPEG, and what I consider to be
  80. the state of the art in still-image compression. For lossless coding I have
  81. compared against Wu's CALIC system, which has been proposed for the lossless
  82. mode of JPEG, and has done well in the first round of tests for that standard.
  83. For lossy coding I have compared against Said and Pearlman's wavelet-based
  84. embedded coder (based on Shapiro's zerotree approach). Both CALIC and the Said
  85. and Pearlman (henceforth S&P) coder exist in slow and fast versions. In each
  86. case the slow version uses an arithmetic coder to improve compression. BTPC and
  87. JPEG can compress color pictures, but S&P and CALIC can not, so the results
  88. here refer only to grayscale images.
  89.  
  90. I have used an extensive set of test images, most of which are available at
  91. links.uwaterloo.ca. Here I give representative results from that testing. The
  92. programs were run on a SparcStation; times are in seconds. I have included only
  93. decoding time - for all methods encoding time is longer. Indeed, for BTPC, I
  94. have not tried to optimize the encoder at all, so it currently takes between
  95. two and three times as long as the decoder to run. The reason for my neglect of
  96. encoding speed is that fast decoding is more important in the applications I am
  97. interested in (e.g. image databases). Nonetheless, BTPC version 3 encoding is
  98. substantially faster than CALIC and S&P.
  99.  
  100. Some caveats
  101. ------------
  102.  
  103. I have chosen CALIC and S&P because I believe them to be the best that is
  104. currently being achieved. Possibly some commercial products do better. I would
  105. like to hear about any that are available for evaluation.
  106.  
  107. Having said this, please bear in mind that BTPC is not intended to beat state
  108. of the art systems like CALIC and S&P in their areas of strength. Rather, it is
  109. supposed to be "general purpose", which means it should do reasonably well over
  110. a wide range of possible inputs, and should run fast. Testing against the state
  111. of the art is a kind of "worst case" comparison, so be warned!
  112.  
  113. One of BTPC's design criteria was decoding speed. I am not sure that this was
  114. the case for CALIC and S&P. However, both Wu, and Said and Pearlman have argued
  115. that their fast versions are fast (!) so I've considered it fair game to make
  116. them compete in a timing comparison.
  117.  
  118. A consequence of designing BTPC as a "general-purpose" coder is that the only
  119. difference between lossless and lossy coding is the quantizer step size. For
  120. better or for worse, I have resisted the idea of a separate lossless "mode",
  121. and I am still not sure of the wisdom of this.
  122.  
  123. 1.     Typical figures for photographic images
  124. -----------------------------------------------
  125.  
  126. Here are two sets of typical results for coding photographic images. These show
  127. the general trend for photos with BTPC falling between JPEG and S&P/CALIC for
  128. compression efficiency, and BTPC and JPEG being much faster than the fast
  129. versions of S&P and CALIC.
  130.  
  131. 512 x 512 Lenna:
  132.  
  133. Lossy coding at PSNR 36.9 dB (= JPEG coded with Q of 75):
  134.  
  135. Scheme                          bpp             Decode time
  136. ------                          ---             -----------
  137.  
  138. JPEG (IJG v 6)                  1.05            1.4
  139. BTPC3                           0.93            1.4
  140. S&P fast                        0.66            5.2
  141. S&P slow                        0.60            8.9
  142.  
  143. Lossless coding:
  144.  
  145. Scheme                          bpp             Decode time
  146. ------                          ---             -----------
  147.  
  148. BTPC3                           4.66            2.9
  149. CALIC fast                      4.40            10.0
  150. CALIC slow                      4.33            24.7
  151.  
  152. 256 x 256 Cameraman:
  153.  
  154. Lossy coding at PSNR 34.7 dB (= JPEG coded with Q of 75):
  155.  
  156. Scheme                          bpp             Decode time
  157. ------                          ---             -----------
  158.  
  159. JPEG (IJG v 6)                  1.34            0.4
  160. BTPC3                           0.95            0.4
  161. S&P fast                        0.91            1.3
  162. S&P slow                        0.82            2.5
  163.  
  164. Lossless coding:
  165.  
  166. Scheme                          bpp             Decode time
  167. ------                          ---             -----------
  168.  
  169. BTPC3                           5.02            0.7
  170. CALIC fast                      4.34            2.4
  171. CALIC slow                      4.31            6.2
  172.  
  173. 2.     BTPC's worst case
  174. -------------------------
  175.  
  176. In my test suite, BTPC's worst case was "achieved" on the 512 x 512
  177. photographic image "Barbara" which includes large areas of stripes. This is the
  178. only picture for which BTPC performed worse than JPEG (and then only
  179. marginally). The reason is that JPEG's DCT is able to exploit the regular
  180. spatial frequency structure of the stripes. BTPC cannot do this. (On the other
  181. hand, BTPC clearly outperforms JPEG on textured pictures with less regular
  182. spatial structure - e.g. Gold Hill.)
  183.  
  184. 512 x 512 Barbara:
  185.  
  186. Lossy coding at PSNR 36.2 dB (= JPEG coded with Q of 75):
  187.  
  188. Scheme                          bpp             Decode time
  189. ------                          ---             -----------
  190.  
  191. JPEG (IJG v 6)                  1.33            1.6
  192. BTPC3                           1.36            1.7
  193. S&P fast                        0.93            5.4
  194. S&P slow                        0.87            10.1
  195.  
  196. Lossless coding:
  197.  
  198. Scheme                          bpp             Decode time
  199. ------                          ---             -----------
  200.  
  201. BTPC3                           5.31            3.0
  202. CALIC fast                      4.59            10.5
  203. CALIC slow                      4.48            26.5
  204.  
  205. 3.     Typical figures for graphical images
  206. --------------------------------------------
  207.  
  208. With purely graphical images, BTPC's performance improves relative to the other
  209. schemes. It consistently compresses more than JPEG, S&P and the fast version of
  210. CALIC. It compresses about the same as the slow version of CALIC, at about nine
  211. times the speed. Here are figures for coding two typical presentation graphics.
  212.  
  213. 496 x 672 France:
  214.  
  215. Lossy coding at PSNR 34.6 dB (= JPEG coded with Q of 75):
  216.  
  217. Scheme                          bpp             Decode time
  218. ------                          ---             -----------
  219.  
  220. JPEG (IJG v 6)                  1.43            1.7
  221. BTPC3                           0.53            1.7
  222. S&P fast                        1.09            7.1
  223. S&P slow                        0.87            14.4
  224.  
  225. Lossless coding:
  226.  
  227. Scheme                          bpp             Decode time
  228. ------                          ---             -----------
  229.  
  230. BTPC3                           0.89            2.2
  231. CALIC fast                      1.40            7.4
  232. CALIC slow                      0.82            21.2
  233.  
  234. The difference between the two CALIC results is correct, and illustrates a
  235. problem with the use of Huffman coding in the CALIC algorithm on highly
  236. redundant images.
  237.  
  238. 372 x 619 World Map:
  239.  
  240. Lossy coding at PSNR 34.4 dB (= JPEG coded with Q of 75):
  241.  
  242. Scheme                          bpp             Decode time
  243. ------                          ---             -----------
  244.  
  245. JPEG (IJG v 6)                  1.83            1.2
  246. BTPC3                           0.63            1.2
  247. S&P fast                        1.52            5.7     [S&P coded a cropped
  248.                                                         version of the image]
  249. S&P slow                        1.27            12.1
  250.  
  251. Lossless coding:
  252.  
  253. Scheme                          bpp             Decode time
  254. ------                          ---             -----------
  255.  
  256. BTPC3                           0.63            1.2
  257. CALIC fast                      1.06            3.2
  258. CALIC slow                      0.61            12.0
  259.  
  260. 4.     Typical figures for multimedia images
  261. ---------------------------------------------
  262.  
  263. Because the relative performance of BTPC and the other schemes is different on
  264. photographs and graphics, mixed or multimedia images can give different
  265. results. Here is an example where photographs are embedded within two-level
  266. graphics (UW Library montage). This favors CALIC which has a special mode for
  267. two-level regions.
  268.  
  269. 352 x 464 Library:
  270.  
  271. Lossy coding at PSNR 30.6 dB (= JPEG coded with Q of 75):
  272.  
  273. Scheme                          bpp             Decode time
  274. ------                          ---             -----------
  275.  
  276. JPEG (IJG v 6)                  2.36            1.1
  277. BTPC3                           1.58            1.1
  278. S&P fast                        1.87            5.8
  279. S&P slow                        1.61            10.6
  280.  
  281. Lossless coding:
  282.  
  283. Scheme                          bpp             Decode time
  284. ------                          ---             -----------
  285.  
  286. BTPC3                           5.42            1.8
  287. CALIC fast                      5.20            6.6
  288. CALIC slow                      5.01            16.4
  289.  
  290. Summary of the Results
  291. ======================
  292.  
  293. Further results are given at http://monet.uwaterloo.ca/~john/btpc.html. The
  294. ones given above are supposed to be representative of the general trends which
  295. I summarize as:
  296.  
  297. 1. Lossless coding. BTPC compression is usually between 5 and 10% less
  298.    efficient than the state of the art, CALIC, for photographs, and about the
  299.    same efficiency as the slow version of CALIC for graphics. It is
  300.    substantially more efficient than the fast version of CALIC for graphics. It
  301.    is about 3.5 times faster than the fast version and about 9 times faster
  302.    than the slow version on average. BTPC requires more memory than CALIC, in
  303.    that the entire picture is held in store. On the other hand, it allow
  304.    progressive decoding.
  305.  
  306. 2. Lossy coding vs JPEG. BTPC is almost always superior to JPEG. On average it
  307.    is about 20% more efficient than JPEG for photographs, at least twice as
  308.    efficient for graphics. Decoding is as fast as the IJG decoding and uses
  309.    slightly more memory. Encoding currently takes between two and three times
  310.    as long as IJG JPEG.
  311.  
  312. 3. Lossy coding vs the state of the art. Embedded coders like S&P and Shapiro's
  313.    seem to be the future of lossy coding for natural images. BTPC is
  314.    competitive on simple pictures (like cameraman, mentioned above), but on
  315.    more textured images can require 50% more bits than S&P for a photograph.
  316.    However, BTPC codes graphics and multimedia images more efficiently, and its
  317.    decoding time is always less than a third that of fast S&P, and usually less
  318.    than a quarter.
  319.  
  320. Patents and Copyright
  321. =====================
  322.  
  323. The BTPC method is patent-free. In particular, no use is made of arithmetic
  324. coding. The source code is copyright (c) 1994, 1995, John A. Robinson, except
  325. for portions of the file colmap.C which are the work of the Independent JPEG
  326. group and therefore copyright (C) 1991, 1992, 1993, 1994, 1995 Thomas G. Lane.
  327. (Previous versions of BTPC contained code from Unix compact: this has now been
  328. replaced.)
  329.  
  330. You may freely use all the BTPC code on exactly the same terms as the
  331. Independent JPEG group allows use of their code. Following their pattern, and
  332. adapting their README file (see READMEJ for the original), here is how it
  333. works:
  334.  
  335. I welcome the use of this software as a component of commercial products. No
  336. royalty is required, but I do ask for an acknowledgement in product
  337. documentation, as described below.
  338.  
  339. In plain English:
  340.  
  341. 1. I don't promise that this software works. (But if you find any bugs,
  342.    please let me know!)
  343. 2. You can use this software for whatever you want. You don't have to pay me.
  344. 3. You may not pretend that you wrote this software. If you use it in a
  345.    program, you must acknowledge somewhere in your documentation that
  346.    you've used the BTPC Version 3 code.
  347.  
  348. In legalese:
  349.  
  350. The author makes NO WARRANTY or representation, either express or implied, with
  351. respect to this software, its quality, accuracy, merchantability, or fitness
  352. for a particular purpose. This software is provided "AS IS", and you, its user,
  353. assume the entire risk as to its quality and accuracy.
  354.  
  355. This software, excluding the file colmap.C, is copyright (C) 1994, 1995, John
  356. A. Robinson, All Rights Reserved except as specified below.
  357.  
  358. Permission is hereby granted to use, copy, modify, and distribute this software
  359. (or portions thereof) for any purpose, without fee, subject to these
  360. conditions:
  361.  
  362. (1) If any part of the source code for this software is distributed, then this
  363. "Patents and Copyright" section of the README file must be included, with this
  364. copyright and no-warranty notice unaltered; and any additions, deletions, or
  365. changes to the original files must be clearly indicated in accompanying
  366. documentation.
  367.  
  368. (2) If only executable code is distributed, then the accompanying documentation
  369. must state that "this software is based in part on Binary Tree Predictive
  370. Coding Version 3, implemented by J. A. Robinson".
  371.  
  372. (3) Permission for use of this software is granted only if the user accepts
  373. full responsibility for any undesirable consequences; the author accepts NO
  374. LIABILITY for damages of any kind.
  375.  
  376. NOTE THAT IF YOU USE THE FILE COLMAP.C YOU MUST COMPLY WITH THE IJG'S TERMS TOO
  377. - SEE THE FILE READMEJ.
  378.