Search code examples
c#dicomimage-compression

Change dicom Transfer Syntax showing no registered codec using mDCM


I am having issue while changing the Transfer Syntax.
I am using mDCM library and I have added the Dicom.Codec.dll to the project as well.
The compressed files are having 0002,0010,Transfer Syntax UID=1.2.840.10008.1.2.4.90 (JPEG 2000 Image Compression (Lossless Only)).
Error: DicomCodecException was caught. No registered codec for transfer syntax!

My code:

string file = "C:\\Dicom\\1001.dcm";
string output = "C:\\Dicom\\Decompressed\\1001.dcm";
DicomFileFormat ff = new DicomFileFormat();
ff.Load(file, Dicom.DicomReadOptions.Default);
ff.ChangeTransferSytnax(DicomTransferSyntax.ExplicitVRLittleEndian, null); // Error here. No registered codec for transfer syntax!.
Dicom.Imaging.DicomImage im = new Dicom.Imaging.DicomImage(ff.Dataset);
System.Drawing.Image i = im.Render();
i.Save(output);

Another thing that I noted is that the tag 7FE0,0010,Pixel Data=0. For other dicom files, Pixel data tag is having values greater than 0.

The file is not opening in my other dicom viewers (ezDICOM, DicomWorks, IrfanView etc.) as well. So, I thought the file is corrupted. But, then the client gave us an application(.exe) which decompresses the file.
After decompression, all my viewers was showing the image properly.
Decompressed files was having 7FE0,0010,Pixel Data=131072.


Solution

  • As the error mentioned, I was not registering the codec.

    This line registered the codec.

    Dicom.Codec.Jpeg2000.DcmJpeg2000Codec.Register();