Bogus Huffman table definition

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ajan_p
Posts: 7
Joined: Mon, 2008-04-28, 08:23
Contact:

Bogus Huffman table definition

#1 Post by ajan_p »

Hi,
I tried converting a DICOM image.
The details of the DICOM Image is as below
The transfersyntax is EXS_JPEGProcess14TransferSyntax
the dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);
throws an error string "Bogus Huffman table definition". can any one help me sorting out this issue
Last edited by ajan_p on Thu, 2011-09-29, 06:15, edited 1 time in total.
Thanks & Warm Regards,
Ajan

J. Riesmeier
DCMTK Developer
Posts: 2512
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#2 Post by J. Riesmeier »

Have you already checked the source code of "dcmjpeg" for this kind of error code?

ajan_p
Posts: 7
Joined: Mon, 2008-04-28, 08:23
Contact:

Issue sorted out

#3 Post by ajan_p »

The issue was sorted out by a change in the source code of dcmjpeg library.
Thanks & Warm Regards,
Ajan

J. Riesmeier
DCMTK Developer
Posts: 2512
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#4 Post by J. Riesmeier »

So, does that mean that there is/was a bug in the dcmjpeg module, which is based on the IJG library, or is the image buggy?

ajan_p
Posts: 7
Joined: Mon, 2008-04-28, 08:23
Contact:

#5 Post by ajan_p »

The error was on IJG library.
Thanks & Warm Regards,
Ajan

J. Riesmeier
DCMTK Developer
Posts: 2512
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#6 Post by J. Riesmeier »

So, could you please tell us what was wrong and what you changed, i.e. could you provide a patch, so we can fix this bug also in the DCMTK. And, are you really sure that this issue was not caused by the DICOM image you've processed?

ajan_p
Posts: 7
Joined: Mon, 2008-04-28, 08:23
Contact:

#7 Post by ajan_p »

Last edited by ajan_p on Fri, 2011-09-23, 09:37, edited 1 time in total.
Thanks & Warm Regards,
Ajan

J. Riesmeier
DCMTK Developer
Posts: 2512
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#8 Post by J. Riesmeier »

Thank you. I guess you are referring to the following patch, right?

Code: Select all

Index: jdhuff.c
===================================================================
RCS file: /cvs/public/gdcm/src/jpeg/libijg8/jdhuff.c,v
retrieving revision 1.1
diff -u -3 -p -r1.1 jdhuff.c
--- jdhuff.c    24 Jun 2003 10:09:48 -0000      1.1
+++ jdhuff.c    7 Oct 2004 02:29:43 -0000
@@ -259,8 +259,11 @@ jpeg_make_d_derived_tbl (j_decompress_pt
   if (isDC) {
     for (i = 0; i < numsymbols; i++) {
       int sym = htbl->huffval[i];
-      if (sym < 0 || sym > 15)
-       ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+      if (sym < 0 || sym > 15) {
+         // Now, we can read Philips MRI Images
+         htbl->huffval[i]=15;
+//     ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+      }
     }
   }
 }
If I interpret the comment correctly, Philips is doing something wrong with their MRI images, don't you agree?

ajan_p
Posts: 7
Joined: Mon, 2008-04-28, 08:23
Contact:

#9 Post by ajan_p »

absolutely right.
Thanks & Warm Regards,
Ajan

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

#10 Post by Uli Schlachter »

Could you upload an example of such a broken image or could you send it to dicom (at) offis (dot) de?

ajan_p
Posts: 7
Joined: Mon, 2008-04-28, 08:23
Contact:

#11 Post by ajan_p »

uploaded the image to the email address
Thanks & Warm Regards,
Ajan

Uli Schlachter
DCMTK Developer
Posts: 120
Joined: Thu, 2009-11-26, 08:15

#12 Post by Uli Schlachter »

Hi,

thanks for the image. However, I don't think we should apply your change to the ijg jpeg library.

JPEG splits the image up in blocks. For each block, the difference between the average luminance of this and the previous blocks gets entropy encoded. This is where the DC Huffman table that we have a problem with is used. Obviously, there is a maximum possible value for this difference. Your JPEG specifies how to encode a difference larger than this maximum possible value in its huffmann table.
Your patch only works because this image doesn't actually use the large value from the DC table.

I have no idea what would happen if this value actually gets used, but I guess that things would blow up in strange ways.

Also, I haven't found anything else which allows reading this broken image.

Uli

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest