ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 IEvolution DICOM to JPEG conversion issue
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

spurgeon

54 Posts

Posted - Jul 13 2020 :  08:47:36  Show Profile  Reply
When converting DICOM to JPEG with IEImage 8.0.0, the resulting image doesn't look right. Is there a way to fix this? For what it's worth, we do not have this issue with ImageEn (Delphi).


IEImage ieImage = new IEImage();
ieImage.LoadImage("brain_001.dcm");
ieImage.SaveImage("brain_001.jpg");
ieImage.Dispose();


Attached are a source DICOM image (brain_001.dcm) and the converted JPEG.

attach/spurgeon/202071384728_brain_001.zip
98.23 KB

xequte

38176 Posts

Posted - Jul 15 2020 :  21:04:10  Show Profile  Reply
Hi

What is the value for DicomRange:

https://www.imageen.com/ievolutionhelp/html/0f7063e1-f3e8-6908-ba24-bbe10f01149e.htm

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spurgeon

54 Posts

Posted - Jul 17 2020 :  10:05:44  Show Profile  Reply
The value of ieImage.IOParams.DICOM_Range after loading brain_001.dcm is 0 (DicomRange.Adjust).

I don't know if this is helpful, but if I load the image into an IEViewer, it renders properly. EDIT: However, when saving the image from the IEViewer, it looks funny again. For example:


    public partial class Form1 : Form
    {
        IEViewer ieViewer;

        public Form1()
        {
            InitializeComponent();
        }

        private async void Form1_Load(object sender, EventArgs e)
        {
            IEImage ieImage = new IEImage();
            ieImage.LoadImage("brain_001.dcm");
            Console.WriteLine("ieImage.IOParams.DICOM_Range:"+ieImage.IOParams.DICOM_Range);
            ieImage.IOParams.DICOM_Range = DicomRange.SetBlackWhite;
            ieImage.SaveImage("brain_001.jpg"); // rendered strangely
            ieImage.SaveImage("brain_001.png"); // rendered strangely
            ieImage.Dispose();

            ieViewer = new IEViewer();
            ieViewer.Dock = DockStyle.Fill;
            ieViewer.Parent = this;
            this.Controls.Add(ieViewer);
            ieViewer.Image.LoadImage("brain_001.dcm"); // Looks great in IEViewer when loaded
            await Task.Delay(TimeSpan.FromSeconds(3));
            ieViewer.Image.SaveImage("ieviewer_brain_001.jpg"); // After saving, the IEViewer is now rendered strangely
            this.Size = new Size(Size.Width + 1, Size.Height); // have to "force" a refresh since IEViewer.Refresh() doesn't seem to work
        }
    }
Go to Top of Page

spurgeon

54 Posts

Posted - Aug 13 2020 :  09:02:52  Show Profile  Reply
I wanted to bump this topic because I need a solution for DICOM images with this issue. Attached are two screenshots from running the sample app code I posted previously. Any thoughts?

After loading brain001.dcm into IEViewer:



IEViewer after saving brain001.dcm as brain001.jpg:

Go to Top of Page

xequte

38176 Posts

Posted - Aug 14 2020 :  00:56:04  Show Profile  Reply
Hi

What are the values of:

IEImage.Format:
https://www.imageen.com/ievolutionhelp/html/2f2ae599-3ca1-19c2-3989-77961898df7d.htm

IEImage.IOParams.BitsPerSample
https://www.imageen.com/ievolutionhelp/html/f23fbe4e-db23-e944-a550-67b8fd58541b.htm

IEImage.IOParams.SamplesPerPixel
https://www.imageen.com/ievolutionhelp/html/b120ada4-61eb-920c-a7a9-2a13343b237a.htm


Does updating them to full color values or calling IEImage.ConvertToTrueColor make any difference?

https://www.imageen.com/ievolutionhelp/html/fb7000e5-b52a-2636-2ddb-4aa0d41ac383.htm


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spurgeon

54 Posts

Posted - Aug 17 2020 :  15:37:44  Show Profile  Reply
Here's what I see:

        private async void Form1_Load(object sender, EventArgs e)
        {
            IEImage ieImage = new IEImage();
            ieImage.LoadImage("brain_001.dcm");

            // Format:ie16g
            // IOParams.BitsPerSample:16
            // IOParams.SamplesPerPixel:1
            printDicomData(ieImage);

            ieImage.SaveImage("brain_001.jpg"); // rendered strangely

            // Format:ie24RGB
            // IOParams.BitsPerSample:16
            // IOParams.SamplesPerPixel:1
            printDicomData(ieImage);

            ieImage.Dispose();

            ieViewer = new IEViewer();
            ieViewer.Dock = DockStyle.Fill;
            ieViewer.Parent = this;
            this.Controls.Add(ieViewer);
            ieViewer.Image.LoadImage("brain_001.dcm"); // Looks great in IEViewer when loaded

            // Format:ie16g
            // IOParams.BitsPerSample:16
            // IOParams.SamplesPerPixel:1
            printDicomData(ieViewer.Image);

            await Task.Delay(TimeSpan.FromSeconds(3));
            ieViewer.Image.SaveImage("ieviewer_brain_001.jpg"); // After saving, the IEViewer is now rendered strangely
            this.Size = new Size(Size.Width + 1, Size.Height); // have to "force" a refresh since IEViewer.Refresh() doesn't seem to work

            // Format:ie24RGB
            // IOParams.BitsPerSample:16
            // IOParams.SamplesPerPixel:1
            printDicomData(ieViewer.Image);
        }

        private void printDicomData(IEImage ieImage)
        {
            Console.WriteLine("Format:" + ieImage.Format);
            Console.WriteLine("IOParams.BitsPerSample:" + ieImage.IOParams.BitsPerSample);
            Console.WriteLine("IOParams.SamplesPerPixel:" + ieImage.IOParams.SamplesPerPixel);
        }


Using IEImage.ConvertToTrueColor() doesn't affect the output when invoked anywhere in this code. I apologize but I don't know what you mean by updating the other values to "full color." Since I have provided a sample project and a sample file, would you be able to look at it on your side to see why this conversion is not working?

With Delphi, I do something similar like this and have no issues with a DICOM -> JPEG conversion:

  io := TImageEnIO.Create(nil);
  iebmp := TIEBitmap.Create;
  io.AttachedIEBitmap := iebmp;
  io.LoadFromFile('brain_001.dcm');
  io.SaveToFile('brain_001.jpg');

Go to Top of Page

xequte

38176 Posts

Posted - Aug 18 2020 :  15:46:40  Show Profile  Reply
Hi

Please use:

      IEImage ieImage = new IEImage();
      ieImage.LoadImage("42\brain_001.dcm");
      ieImage.Format = IEImage.PixelFormat.ie24RGB;
      ieImage.SaveImage("\test.jpg");
      ieImage.Dispose();


Note: In the next version, you won't need to explicitly specify the Pixel Format, as it will convert automatically.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spurgeon

54 Posts

Posted - Aug 21 2020 :  11:52:45  Show Profile  Reply
Thanks, appreciate it and I'll watch for the next update as well.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: