To all:

Here is a summary of replies to a question I posed some time ago concerning
the lossless Huffman encoding of JPEG compressed images. I'm sorry for
taking so long, but I received numerous replies that took quite a while to
investigate. Thanks to all who gave suggestions.

My original query was:

Does anyone have source code for reading JPEG compressed images that they
would be willing to share. Specifically, I am looking for software that can
read the Lossless Huffman encoding. This is the default standard for DICOM
files. At present, I must go through a rather painful process of loading
the files into Osiris and saving them in an uncompressed DICOM format. This
is fine for the occasional file, but when I must convert 60+ images at a
time, it becomes very frustrating and time consuming. I frequently receive
DICOM files for analysis, and some of them are JPEG compressed. I have a
program that I wrote to convert a series of DICOM files into one AVS field
file. I would like to include source code for reading these compressed

I have tried using "FreeImage" from It will read a variety
of compression formats, including numerous JPEG encodings, but the one that
it will not read is the Lossless Huffman. I am aware of a several available
libraries for reading DICOM files, but each one comes at a premium price.

Summary of replies:

Most of the replies referred me to the International JPEG Group (IJG) web
site ( They have free source code for reading several JPEG
formats. Unfortunately, none of these are the lossless Huffman encoding.
In addition, I discovered that the JPEG portion of the FreeImage library is
largely based on the IJG software. Cornell University has a rather well
known version that can read the lossless encoding, but as noted on the IJG
web site "Caution: the Cornell coder is known to have bugs for 16-bit data."
>From what I have been able to determine, this is in fact true.

Other replies included references for MATLAB, a Java implementation
(, ImageJ, and more. These all proved to be
too great an effort to implement in my C++ code to justify the time and
expense. However, these might be of use for someone else.

After further investigation, I was directed to another application on ( XMedCon is an
application for reading DICOM files and includes a lossless Huffman JPEG
decoder. As it turns out, this is the Cornell code with a few bug fixes.
Moreover, its format made it easier to use and test. Fortunately, after a
bit of debugging effort, I was able to produce a working decoder. For those
who need to be able to read such JPEG compressed images (or need any number
of other applications), is an excellent source.

I hope that someone else finds this useful.


Jim Ziegler
James M. Ziegler, Ph.D., P.E.
Ncompass Research, Inc.
5615 Belrose Drive
Houston, Texas, 77035-2609

To unsubscribe send SIGNOFF BIOMCH-L to
For information and archives: