How to generate DICOM JPEG compression image without JFIF header
Moderator: Moderator Team
-
- Posts: 4
- Joined: Mon, 2019-04-22, 10:51
How to generate DICOM JPEG compression image without JFIF header
Hi, Teachers,
I am a DICOM developer from china. I am developping a project on JPEG compression。 and I used transfer syntax 1.2.840.10008.1.2.4.70. I tried to use sample code of DCMTK org to compress XA(monochrome2 and multi-frames) DICOM image. but the compressed image cannot be decompressed by other storage scp such as JDICOM tool. And error info is "the marker ffe0 can not be recognized". I downloaded some XA sample dicom files with JPEG compression. And I found there are no JFIF header.
Firstly, as My understanding, JFIF header should not exist in DICOM jpeg file. Could you please confirm if My understanding is right or not?
If my understanding is right, why is there JFIF header in DCMTK jpeg compression file for photometric interpretation "monochrome2"。 I am confused. should have JFIF header in JPEG compression DICOM file?
I expected your reply. Thanks so much.
Regards,
Tony
I am a DICOM developer from china. I am developping a project on JPEG compression。 and I used transfer syntax 1.2.840.10008.1.2.4.70. I tried to use sample code of DCMTK org to compress XA(monochrome2 and multi-frames) DICOM image. but the compressed image cannot be decompressed by other storage scp such as JDICOM tool. And error info is "the marker ffe0 can not be recognized". I downloaded some XA sample dicom files with JPEG compression. And I found there are no JFIF header.
Firstly, as My understanding, JFIF header should not exist in DICOM jpeg file. Could you please confirm if My understanding is right or not?
If my understanding is right, why is there JFIF header in DCMTK jpeg compression file for photometric interpretation "monochrome2"。 I am confused. should have JFIF header in JPEG compression DICOM file?
I expected your reply. Thanks so much.
Regards,
Tony
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How to generate DICOM JPEG compression image without JFIF header
Hi,
the JFIF header is actually permitted in DICOM, see part 5 (number #3 in section on JPEG compression).
I don't think the DCMTK JPEG compressor (or the related tool dcmcjpeg) does make use of any JFIF header information.
Best regards,
Michael
the JFIF header is actually permitted in DICOM, see part 5 (number #3 in section on JPEG compression).
I don't think the DCMTK JPEG compressor (or the related tool dcmcjpeg) does make use of any JFIF header information.
Best regards,
Michael
-
- Posts: 4
- Joined: Mon, 2019-04-22, 10:51
Re: How to generate DICOM JPEG compression image without JFIF header
Hi Michael,
Thanks for your reply.
Actually, I used sample code "https://support.dcmtk.org/docs/mod_dcmjpeg.html" to compress XA image. I can find the following marker in compressed file.
"FF D8 FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00 FF C3"
There is APP0 info between FF D8 and FF C3. Is this correct?
I found there is no such APP0 info in some sample DICOM JPEG image.
Could you please send me a sample XA DICOM image with JPEG Lossless(1.2.840.10008.1.2.4.70)?
Regards,
Tony
Thanks for your reply.
Actually, I used sample code "https://support.dcmtk.org/docs/mod_dcmjpeg.html" to compress XA image. I can find the following marker in compressed file.
"FF D8 FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00 FF C3"
There is APP0 info between FF D8 and FF C3. Is this correct?
I found there is no such APP0 info in some sample DICOM JPEG image.
Could you please send me a sample XA DICOM image with JPEG Lossless(1.2.840.10008.1.2.4.70)?
Regards,
Tony
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How to generate DICOM JPEG compression image without JFIF header
Hi,
maybe the file you are compression is already JPEG compressed so your API calls do not have any effect at all? Use the dcmdump tool and look at the Transfer Syntax denoted in the DICOM meta header to find out.
To create a JPEG-compressed DICOM file just use the tool dcmcjpeg from DCMTK. It compresses an existing uncompressed DICOM file to JPEG transfer syntax(es). You just need to call
where input.dcm is the uncompressed input DICOM file and output.dcm is the desired JPEG-compressed output filename.
Best,
Michael
maybe the file you are compression is already JPEG compressed so your API calls do not have any effect at all? Use the dcmdump tool and look at the Transfer Syntax denoted in the DICOM meta header to find out.
To create a JPEG-compressed DICOM file just use the tool dcmcjpeg from DCMTK. It compresses an existing uncompressed DICOM file to JPEG transfer syntax(es). You just need to call
Code: Select all
dcmcjpeg input.dcm output.dcm
Best,
Michael
-
- Posts: 4
- Joined: Mon, 2019-04-22, 10:51
Re: How to generate DICOM JPEG compression image without JFIF header
Michael,
Thanks for your comments.
I try to compress my original DICOM file(Un-compression, XA, MONOCHROME2) to JPEG transfer syntax with "dcmcjpeg input.dcm output.dcm". And I found there still is APP0 info " FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00" in output.dcm. Such file with APP0 info cannot be de-compressed by other DICOM tool such as JDICOM.
I want to confirm if compressed DICOM file with APP0 info is correct or not and why all other sample compression DICOM files I get from internet do not include APP0 info?
Could you please send me sample compressed DICOM file(XA, MONOCHROME2)which is compressed by DCMTK? I want to check if APP0 info exist.
Thanks so much for your help.
Tony
Thanks for your comments.
I try to compress my original DICOM file(Un-compression, XA, MONOCHROME2) to JPEG transfer syntax with "dcmcjpeg input.dcm output.dcm". And I found there still is APP0 info " FF E0 00 10 4A 46 49 46 00 01 01 00 00 01 00 01 00 00" in output.dcm. Such file with APP0 info cannot be de-compressed by other DICOM tool such as JDICOM.
I want to confirm if compressed DICOM file with APP0 info is correct or not and why all other sample compression DICOM files I get from internet do not include APP0 info?
Could you please send me sample compressed DICOM file(XA, MONOCHROME2)which is compressed by DCMTK? I want to check if APP0 info exist.
Thanks so much for your help.
Tony
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How to generate DICOM JPEG compression image without JFIF header
Hi Tony,
I think you are right, the JFIF header is in the file. I actually though it's not inside, sorry for misdirecting you. I had a different behaviour in mind since the img2dcm tool removes the JFIF header when converting JPEG to DICOM.
It is not possible to disable the existance of JFIF header information (FF D8 FF E0...) in files produced by the DCMTK JPEG compressor. However, note that as I stated earlier, that this behaviour is covered by the DICOM standard.
I uploaded an image (XA, MONOCHROME2, originally found on the Internet) compressed by DCMTK here: http://dicom.guru/download/xa_jpeg_lossless.dcm .
Best regards,
Michael
I think you are right, the JFIF header is in the file. I actually though it's not inside, sorry for misdirecting you. I had a different behaviour in mind since the img2dcm tool removes the JFIF header when converting JPEG to DICOM.
It is not possible to disable the existance of JFIF header information (FF D8 FF E0...) in files produced by the DCMTK JPEG compressor. However, note that as I stated earlier, that this behaviour is covered by the DICOM standard.
I uploaded an image (XA, MONOCHROME2, originally found on the Internet) compressed by DCMTK here: http://dicom.guru/download/xa_jpeg_lossless.dcm .
Best regards,
Michael
-
- Posts: 4
- Joined: Mon, 2019-04-22, 10:51
Re: How to generate DICOM JPEG compression image without JFIF header
Michael,
Thanks so much for your confirmation and sample image.
I found a solution that there is no APP0 info( FF E0...) in compressed JPEG file by DCMTK. My test file is XA image with photo metric interpretation "MONOCHROME2".
My solution is:
1, Set value of tag PhotoMetricInterpretation(0028,0004) to null before compressing like following:
2, Compress data like following:
3,Reset value of tag PhotoMetricInterpretation(0028,0004) to "MONOCHROME2".
As my solution, there will be no APP0 info(FF E0...) in compressed JPEG file. And compressed file can be decompressed by other storageSCP tool such "JDICOM". Could you please confirm if my solution is feasible or not?
Tony
Thanks so much for your confirmation and sample image.
I found a solution that there is no APP0 info( FF E0...) in compressed JPEG file by DCMTK. My test file is XA image with photo metric interpretation "MONOCHROME2".
My solution is:
1, Set value of tag PhotoMetricInterpretation(0028,0004) to null before compressing like following:
Code: Select all
dataset->findAndGetElement(DCM_PhotometricInterpretation, pPhotometric);
pPhotometric->putString("");
Code: Select all
dataset->chooseRepresentation(EXS_JPEGProcess14V1, ¶ms);
As my solution, there will be no APP0 info(FF E0...) in compressed JPEG file. And compressed file can be decompressed by other storageSCP tool such "JDICOM". Could you please confirm if my solution is feasible or not?
Tony
-
- DCMTK Developer
- Posts: 2051
- Joined: Fri, 2004-11-05, 13:47
- Location: Oldenburg, Germany
- Contact:
Re: How to generate DICOM JPEG compression image without JFIF header
I tried a file with empty Photometric Interpretation with DCMTK's dcmcjpeg tool (which does basically the same as calling changeRepresentation) and for me the JFIF information is present in the resulting file. My first impression from looking at the JPEG compressor code is that it always writes such markers. Are you sure your call to changeRepresentation() actually works at all?
Maybe my DCMTK colleague Marco knows by heart, since he wrote the code many years ago.
I find it hard to imagine that JDICOM and other tools cannot decompress files with such JPEG markers. Maybe something else is fishy in your code. Maybe you should also try dcmcjpeg to compress your uncompressed file (dcmcjpeg uncompressed.dcm jpeg.dcm) and then try to send/use that with JDICOM.
Best regards,
Michael
Maybe my DCMTK colleague Marco knows by heart, since he wrote the code many years ago.
I find it hard to imagine that JDICOM and other tools cannot decompress files with such JPEG markers. Maybe something else is fishy in your code. Maybe you should also try dcmcjpeg to compress your uncompressed file (dcmcjpeg uncompressed.dcm jpeg.dcm) and then try to send/use that with JDICOM.
Best regards,
Michael
Who is online
Users browsing this forum: No registered users and 1 guest