0
votes

I need to extract a DICOM image from a file and convert it to a standard bitmap. This is the code I have, using fo-dicom:

    Bitmap bmp;
    try
    {
        var image = new DicomImage(Context.Server.MapPath("~/IM-0001-0000.dcm"));
        bmp = new Bitmap(image.RenderImage());
    }
    catch (Exception exception)
    {
        //for breakpoint purposes
        throw;
    }

However, it fails with the following message:

No codec registered for tranfer syntax: JPEG 2000 Image Compression

I'm not an expert on medical imaging, and Google doesn't turn up anything useful. I installed fo-dicom via NuGet, so I suppose all required references are already in the project. What am I missing?

2
I'm not finding documentation for this new-ish lib, you might have better luck trying out their support forum, on which here is one post regarding the same error message (though different transfer syntax), perhaps this post can be of some help. - Chris O
@ChrisO Yep, I've seen this post, still no luck. And AFAIK, there is no documentation. Are there any better alternatives? - Maciej Stachowski
ClearCanvas (open source) is a more mature SDK, so it might support JPEG 2000 out of the box. MergeCom (payware) might also support this. Though I've worked with DICOM for some years now, never had a need to support JPEG 2000, that format never really took off. FWIW, common radiology datasets tend to be JPEG Lossless (or uncompressed) and cardiology datasets tend to be JPEG lossy. - Chris O
@ChrisO I tried a few more files and managed to open a raw one, but neither of JPEG variations seem to work. I guess I'll try ClearCanvas, though it seems to be way too complicated for something that shouldn't be more than 3 lines of code in a student project. - Maciej Stachowski
OK, I just tried a JPEG 2000 sample with fo-dicom from NuGet, I can decompress a sample file just fine, don't get the no codec error message. I think the clue is that your ASP.NET app is having problems loading the native DLLs, let me try to find some advice on that problem. ASP has some weirdness with paths for native DLLs, could be that it cannot find them which might lead to the codec error. - Chris O

2 Answers

2
votes

I had the same problem and solved it by changing the target platform from 64 bit to 32 bit. this is how you can do it on visual studio 2013, but must be pretty much the same in other versions project tab-->properties-->build tab-->platform target

0
votes

I'm using fo-dicom 2.0.2, had same issues, fixed by coping Dicom.Native.dll in same directory as .exe and install Visual C++ Redistributable Packages for Visual Studio 2013 https://www.microsoft.com/en-us/download/details.aspx?id=40784