Compression Software

Rob Harper harper at convex.csc.FI
Mon Dec 9 10:04:06 EST 1991


In <1991Dec8.230508.6265 at ncsu.edu> nmodena at unity.ncsu.edu (Stephen Modena) writes:

>And I'd say "wake up" to this JPEG algorithm, Folks, 'cuz I just read in
>INFO WORLD (or was it PC Week) that Chips & Technology and another
>company are producing a chip set that will do JPEG
>decompression/decompression on the fly for MultiMedia (you know, movies
>on your PC screen).


OK I was interested in this Jpeg business so I did some experiments with
the visualization folks at CSC. They did the work I only report the
results.

As you might know there is a wealth of gif pictures on nic.funet.fi
Well we took oldmill.gif which is a rather complicated and intricate
picture and processed it in various ways.                             
                                  
! You can ftp oldmill.gif from nic.funet.fi from the following directory
! and as you can se its size is 744 K
sun4 /tmp/pj 143> cp ~pub/gif/pics/views/oldmill.gif .
sun4 /tmp/pj 144> l
total 748
drwxr-xr-x  2 pj            512 Dec  9 12:10 ./
drwxrwxrwt 15 bin         11264 Dec  9 12:10 ../
-rw-r--r--  1 pj         743845 Dec  9 12:10 oldmill.gif

! We did an image convert to get om.rppm which is a "rough portable pixal map"
! and the GIF increases in size to 2.3 mega... gag!!!!
sun4 /tmp/pj 147> imconv  oldmill.gif om.rppm 
cjpeg sun4 /tmp/pj 148> l
total 3069
drwxr-xr-x  2 pj            512 Dec  9 12:13 ./
drwxrwxrwt 15 bin         11776 Dec  9 12:13 ../
-rw-r--r--  1 pj         743845 Dec  9 12:10 oldmill.gif
-rw-r--r--  1 pj        2359312 Dec  9 12:13 om.rppm

!If you now run cjpeg (compress jpeg) on the .rppm file it will
!compress it to 336 K which is a compression factor of better than 2:1
!against the original GIF file
sun4 /tmp/pj 149> cjpeg om.rppm > om.jpg
set time = 0
sun4 /tmp/pj 150> set time = 0
sun4 /tmp/pj 151> l
total 3413
drwxr-xr-x  2 pj            512 Dec  9 12:14 ./
drwxrwxrwt 15 bin         11776 Dec  9 12:15 ../
-rw-r--r--  1 pj         743845 Dec  9 12:10 oldmill.gif
-rw-r--r--  1 pj         336185 Dec  9 12:15 om.jpg
-rw-r--r--  1 pj        2359312 Dec  9 12:13 om.rppm
0.0u 0.0s 0:00.14 78.5% 0+103k 2+0io 0pf+0w

!If you try to xv the .jpg file then Xwindows will choke. There may be some
!patches about to handle .jpg files but we do not have them on our machine.
sun4 /tmp/pj 152> xv om.jpg
xv: 'om.jpg' not in a recognized format.
0.1u 0.3s 0:03.17 13.2% 0+235k 12+0io 9pf+0w
Exit -1

! When using djpeg (decompress jpeg) to unpack the .jpg fil it takes
! 23.1 cpu and the om.ppm file can be viewed with xv with no observable
! loss in quality.
sun4 /tmp/pj 153> djpeg om.jpg > om.ppm
23.1u 3.4s 1:10.88 37.5% 0+187k 118+361io 28pf+0w
sun4 /tmp/pj 154> xv om.ppm &

! The rule of thumb would seem to be that if you have intricate images
! with lots of colours and great detail then they are most suitable
! for Jpeg compression. If you have images which only have a few basic
! colours and are very simple in outline then you might get better
! compression with GIF. ( Statement by Graphics expert at CSC )

! Yes but you are asking do you need to go to a .ppm file before
! using cjpeg, and the answer is *NO* you can go straight from GIF to
! JPG (cpu 26.8) 
sun4 /tmp/pj 159> cjpeg oldmill.gif > oldm.jpg
26.8u 3.8s 0:57.72 53.1% 0+152k 162+94io 96pf+0w

! However when you djpeg and expect it to go back to a
! GIF file in **actual fact** it goes to a .PPM file (23.5 cpu)
sun4 /tmp/pj 160> djpeg  oldm.jpg > oldm.gif
23.5u 3.6s 1:22.52 33.0% 0+187k 155+373io 49pf+0w

! we can view the oldm.gif with xv (time to load the picture 10.5 cpu)
! but it really is *not* a GIF, it is a PPM which is obvious when you look
! at the sizes of the files
sun4 /tmp/pj 161> xv oldm.gif
10.5u 4.5s 1:03.64 23.5% 0+1696k 307+0io 323pf+0w

! Here you see that oldm.gif is exactly the same size as om.ppm or
! om.rppm
sun4 /tmp/pj 162> l
total 8396
drwxr-xr-x  2 pj            512 Dec  9 12:28 ./
drwxrwxrwt 15 bin         11264 Dec  9 12:30 ../
-rw-r--r--  1 pj        2359312 Dec  9 12:29 oldm.gif
-rw-r--r--  1 pj         336185 Dec  9 12:27 oldm.jpg
-rw-r--r--  1 pj         743845 Dec  9 12:10 oldmill.gif
-rw-r--r--  1 pj         336185 Dec  9 12:15 om.jpg
-rw-r--r--  1 pj        2359312 Dec  9 12:17 om.ppm
-rw-r--r--  1 pj        2359312 Dec  9 12:13 om.rppm

! So Jpeg it would seem is useful for compressing files but when you
! want to view them you will have to generate LARGE .PPM files
! (But then again I am a microbiologist and not a graphics expert
! I am sure there must be a work around  so you can view .jpg files
! directly from xv)

! OK here is the most interesting part of the exercise if you give the
! option -Q you can choose a value between 0-100 which will cause the
! jpg file to be *REDUCED* even further in size. With the 25% option it
! takes 24.2 cpu instead of 26.8 cpu to do the compression, and when you
! look at the size of 025.jpg it is only 145 K instead of the original
! 744 K gif file which is a compression factor of 5:1
sun4 /tmp/pj 163> cjpeg -Q25 oldmill.gif > o25.jpg
24.2u 2.8s 0:44.01 61.6% 0+151k 136+45io 97pf+0w
sun4 /tmp/pj 164> l
total 8548
drwxr-xr-x  2 pj            512 Dec  9 12:33 ./
drwxrwxrwt 15 bin         11264 Dec  9 12:34 ../
-rw-r--r--  1 pj         143908 Dec  9 12:34 o25.jpg
-rw-r--r--  1 pj        2359312 Dec  9 12:29 oldm.gif
-rw-r--r--  1 pj         336185 Dec  9 12:27 oldm.jpg
-rw-r--r--  1 pj         743845 Dec  9 12:10 oldmill.gif
-rw-r--r--  1 pj         336185 Dec  9 12:15 om.jpg
-rw-r--r--  1 pj        2359312 Dec  9 12:17 om.ppm
-rw-r--r--  1 pj        2359312 Dec  9 12:13 om.rppm
0.0u 0.1s 0:00.26 69.2% 0+120k 2+0io 1pf+0w

! The truly amazing thing is that if you decompress the o25.jpg file
! then you will again get a .ppm file that is 2.3 mega, and to my eyes
! there was no loss in definition or quality when compared to the original
! GIF file.
! Decompressing the o25.jpg took 19.5 cpu compared to 23.5 cpu for oldm.jpg
! So you gain on the roundabouts as well as the swings
sun4 /tmp/pj 165> djpeg o25.jpg > o25.ppm
19.5u 3.1s 0:44.00 51.6% 0+187k 48+330io 16pf+0w
sun4 /tmp/pj 166> xv o25.ppm 

If there is some option for viewing .jpg files without decompressing them
then this looks like a very valuable programme for people who have to
handle images. If you want the  Unix sources for jpeg you will find them on
nic.funet.fi via anonymous ftp.

sun4 /pub/sci/graphics/programs/jpeg 31> dir
total 302
drwxrwxr-x  3 kouhia   ftp           512 Oct  9 11:11 ./
drwxrwxr-x 30 kouhia   ftp          1024 Dec  9 11:06 ../
-rw-rw-r--  1 kouhia   ftp         19048 Oct  7 19:54 README
drwx------  2 kouhia   ftp           512 Oct  9 11:08 early/
-rw-rw-r--  1 kouhia   ftp        272188 Oct  9 10:56 jpegsrc.v1.tar.Z

If you want them for other platforms then an xarchie on jpeg turns up
lots of sites... so I will leave that as an excerise for the enthusiastic.



More information about the Bio-soft mailing list