Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[.NetCore]Encoding to JPEG2000Lossless is not handled correctly #1099

Closed
pengchen0692 opened this issue Aug 25, 2020 · 10 comments
Closed

[.NetCore]Encoding to JPEG2000Lossless is not handled correctly #1099

pengchen0692 opened this issue Aug 25, 2020 · 10 comments
Labels

Comments

@pengchen0692
Copy link
Contributor

Describe the bug
When transcode from ExplicitVRLittleEndian to JPEG2000Lossless, the image is not converted correctly

To Reproduce

  1. Convert given file to JPEG2000Lossless by C# code :
string file = @"Input.dcm";
DicomFile dicomFile = DicomFile.Open(file);
DicomTranscoder transcoder = new DicomTranscoder(dicomFile.Dataset.InternalTransferSyntax, 
DicomTransferSyntax.JPEG2000Lossless);
transcoder.Transcode(dicomFile).Save("output.dcm");
  • Expected:
    The converted image should be same as original

  • Actual:
    It looks like over exposed

Screenshots or test DICOM files

Original Image:
image
Converted Image:
image
Original dicomFile:
Input.zip
Converted DicomFile:
Output.zip

Environment
Fellow Oak DICOM version: ( 4.0.6)
OS: Windows 10 x64
Platform: .NetCore 3.1

@kira-96
Copy link
Contributor

kira-96 commented Aug 26, 2020

if you are building netcore and running on linux, then you can also take a look at https://github.com/Efferent-Health/Dicom-native. They shared their codec that runs on every netcore platform.

Refer to Native codecs on .NET

TranscoderManager.SetImplementation(Efferent.Native.Codec.NativeTranscoderManager.Instance);

string file = @"Input.dcm";
DicomFile dicomFile = DicomFile.Open(file);
DicomTranscoder transcoder = new DicomTranscoder(dicomFile.Dataset.InternalTransferSyntax,
DicomTransferSyntax.JPEG2000Lossless);
transcoder.Transcode(dicomFile).Save("output.dcm");

It works well.

Converted DicomFile:
output.zip

@amoerie
Copy link
Collaborator

amoerie commented Aug 26, 2020

I agree that for .NET core the recommended transcoder is the codecs by Efferent, but if we provide a managed decoder it should work. @gofal provided this decoder, so he's probably in the best position to investigate this problem.

Do note that the efferent transcoders do not seem to support multithreading on the same image, but that's still under investigation. See here Efferent-Health/fo-dicom.Codecs#9

@pengchen0692
Copy link
Contributor Author

Thanks @kira-96 @amoerie :)
I think Efferent is a very good alternative which has better performance and scope, one problem I encounter into is latest Efferent bound to fo-dicom 5.0 which is still prerelease version -- it's not convincing to use a prerelease version in production environment.

@amoerie
Copy link
Collaborator

amoerie commented Aug 26, 2020

No the latest stable release of the efferent codecs should be fine, they've been around for a while. You shouldn't need any pre-release versions, neither from fo-dicom or efferent.

It's just that starting from fo-dicom 5.x, the efferent codecs will be the officially endorsed codecs and we will phase out the old codecs that are embedded in fo-dicom. That's why the efferent codecs are changing names, so that it's obvious they are the "official ones" going from 5.x forward.

@pengchen0692
Copy link
Contributor Author

@amoerie Perfect, I'm not aware they have a different name before!
image

@amoerie amoerie added bug and removed new labels Aug 27, 2020
@amoerie
Copy link
Collaborator

amoerie commented Aug 27, 2020

@gofal quick summary so far: there seems to be an issue in the managed decoder of JPEG Lossless, sample DICOM file can be found at the top. There is an easy workaround: use the latest stable efferent codecs. But perhaps we should also fix this issue in the managed decoder, no?

@gofal
Copy link
Contributor

gofal commented Aug 30, 2020

@amoerie where is this managed JpegLossless decoder invoked? The issue is about encoding from uncompressed to J2kLosless. Then the output is rendered wrong, wo fo-dicom uses the j2kLossless decoder to render. JpegLossless is not involved in this all?

@amoerie
Copy link
Collaborator

amoerie commented Aug 30, 2020

@amoerie where is this managed JpegLossless decoder invoked? The issue is about encoding from uncompressed to J2kLosless. Then the output is rendered wrong, wo fo-dicom uses the j2kLossless decoder to render. JpegLossless is not involved in this all?

I was mixing J2K with JPEG lossless, and misread the issue as a decoding problem instead of an encoding one. Please disregard what I said 😳

@gofal
Copy link
Contributor

gofal commented Aug 31, 2020

related to #1083?

@gofal gofal removed their assignment Oct 5, 2020
@gofal gofal added wontfix and removed bug labels Oct 5, 2020
@gofal
Copy link
Contributor

gofal commented Oct 5, 2020

It will be hard to fix this in Jpeg2k codec. If there is anyone who knows how to fix it, then you are welcome.
Since the codec from Efferent is working, I will close this issue as "wontfix".

Please reopen this if you think there is still something left open to do.

@gofal gofal closed this as completed Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants