I have a question regarding DICOM standard and libjpeg library. In the DICOM standard, there are, among others, Transfer Syntax:
JPEG Lossless, Nonhierarchical, First- Order Prediction (Processes 14 [Selection Value 1]): Default Transfer Syntax for Lossless JPEG Image Compression
As far as I know, this Transfer Syntax corresponds with JPEG-1 Lossles format. I started researching libjpeg library and I found out that it doesn't support (?) Lossless JPEG, as stated here: JPEG Lossless in DICOM
Also, in libjpeg documentation there is a part saying:
Unsupported ISO options include: * Hierarchical storage * Lossless JPEG * DNL marker * Nonintegral subsampling ratios
However, in library code, in compression parameters structure jpeg_compress_struct
there is a field:
boolean lossless; /* TRUE=lossless encoding, FALSE=lossy */
What does is all mean? I'm really confused. Could anyone describe which standards of JPEG are supported by the library? Furthermore, how to set parameters for compression to be compatible with DICOM JPEG Lossless standard?
Let's do some clarifications here first. What you should start with is the famous JPEG 6b (aka 62) release. Start by reading the code from here. You'll discover that there is no mention to your boolean lossless
. libjpeg 6b is the reference codebase that served two forks:
SmartScale
extensiondcommander
libjpeg-turbo, in particular reads the comments from here.So if this is the libjpeg
you were talking about, then yes it does not support the lossless mode specified in the standard. The lossless patch was created by Ken Murchison, and you should still be able to find it (eg. here). It should apply directly over libjpeg 6b. If you do not want to patch the lib yourself, have a quick look at GDCM and or DCMTK, since they are both using a convenient copy of libjpeg + the famous lossless patch (with some further patch, thanks to DCMTK team).
At this point this should answer your question.
For further details on libjpeg (IJG) and libjpeg-turbo informations I suggest you read informations from:
In case you are still reading, I sugest you also have a quick look at another library (purposely) also called libjpeg
, see it here at github. In particular go over the README
file (here). And you'll discover that this libjpeg
is a full implementation of ITU 81 (lossy, lossless, 8/12/16bits and even hierarchical all in one single code, without the need to do multiple compilations !).
And for completeness, I found that the following links were very usefull: