Syntax question

Questions regarding the DCMJP2K library, a DCMTK add-on that implements support for JPEG 2000 compression (lossy and lossless) in DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
JL
Posts: 33
Joined: Sun, 2004-11-14, 00:05
Location: US

Syntax question

#1 Post by JL »

Hello,
I have problems trying to understand how the "dcmcjp2e" executable functions. According to the instruction, in lossy mode, to specify compression ratio, I need to type in something like

dcmcjp2e +ey –r 0.3 Orig.dcm Final.dcm

But I got a “Too many parameters” error message.

Also, in lossy mode, if I want to specify file size, e.g. original file size is 16MB, I want to compress it to 8MB, I typed

dcmcjp2e +ey –s 8192 Orig.dcm Final.dcm

I got the same “Too many parameters” error message

Would you be able to tell me what syntax error I have made and what are the correct syntax I should be using?

Thanks in advance
Regards,
John

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

Are you sure that you really used the minus sign ("-") for the options "-r" and "-s", respectively? From your posting, I suspect that you are using a dash ("–") which is a different character and, therefore, results in a wrong interpretation of the command line arguments.

JL
Posts: 33
Joined: Sun, 2004-11-14, 00:05
Location: US

#3 Post by JL »

Hello,
Thanks for the info. I used “-“ not “_” in the command line. I did mix “_” in the naming the input/output file. I regenerated the DOS prompt error as below.

“…>dcmcjp2e +ey -s 8192 DCM3.dcm DCM3_testlossy_File.dcm
$dcmtk: dcmcjp2e v3.5.3 2004-05-27 $

dcmcjp2e: Encode DICOM file to JPEG 2000 transfer syntax
error: Too many parameters”

However, if I used the following command prompt, the executable ran successfully.

“…>dcmcjp2e +ey -s 8000 DCM3.dcm DCM3_File.dcm”

Here are my other questions about the usage (File size of the source is 16,652kB):

1/ Ratio test: I want the .exe to compress the dicom file by 30%. So I typed in:
“dcmcjp2e +ey -r 0.3 DCM3.dcm DCM3_r30.dcm”
The output file size is 1,816kB. I was expecting 4995kB (30% of 16,652).
Here are some of the results I compiled and with the results I expected in brackets:

-r =.05 output filesize = 602kB (832kB – 5% of the original)
-r =.1 output filesize = 1,188kB (1665kB – 10%)
-r =.2 output filesize = 1,816kB (3330kB – 20%)
-r =.3 output filesize = 1,816kB (4995kB – 70%)
-r =.5 output filesize = 1,816kB (8326kB – 50%)
-r =.7 output filesize = 1,816kB (11656kB – 70%)
-r =.95 output filesize = 1,816kB (15819kB – 95%)

Why is the “-r” parameter so indifferent to the input?

2/ Size test: following the instruction, I want the exe to compress the file to a given size in byte. The command prompt used is something like this:
“…>dcmcjp2e +ey -s 8000 DCM3.dcm DCM3_S8000.dcm”

Here are the results:

-s = 2000 output filesize = 6kB (2000bytes)
-s = 8000 output filesize = 12kB (8000 bytes)
-s = 12000 output filesize = 16kB (12000 bytes)
-s = 10000000 output filesize = 1816kB (10000000 bytes)

Why is the “-s” also insensitive to the input command? Did I do anything wrong?

Please advise.

Regards,
John

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1435
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#4 Post by Marco Eichelberg »

Thanks for the info. I used “-“ not “_” in the command line.
No. You did use neither the minus characer nor underscore, but another character named dash, which is not recognized as starting a command line option.
Ratio test
When choosing a compression ratio, two things must be kept in mind. First of all, the JPEG 2000 algorithm typically achieves a lossless compression ratio of about 4:1, depending on the image input. That means, no matter which ratio you specify, JPEG 2000 will never produce more data than needed for a "pseudo lossless" encoding. The encoding is actually not completely lossless because the color space conversion and floating point wavelet transform cause rounding errors, but it is the best quality that can be achieved with the lossy JPEG 2000 process. For ratios smaller than that, JPEG 2000 will try to achieve a close match. Secondly, the compression ratio is computed relative to the size of the uncompressed DICOM image, without meta-data and without overhead caused by unused bits in the uncompressed DICOM pixel representation. Comparing file sizes does not work, this is not how you determine the size of a DICOM image. The uncompressed pixel data size (in bits) is Rows x Columns x Number of Frames x Samples per Pixel x Bits Stored, and the compression ratio is relative to this number.
Size test
Again, looking at file sizes doesn't work. Each DICOM file has meta-data which accounts for an overhead of typically 2-4 kByte, depending on the SOP class and various other factors. Use the dcmdump tool from our DICOM toolkit (DCMTK) to see the size of the second item (fragment) of pixel data - this is the number you want to compare with your -s parameter. Assuming a header size (overhead) of ca. 4 KB in your sample, your measured file sizes would fit pretty well.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest