Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, August 31, 2017 4:07:19 PM(UTC)
Nick Villalobos

Groups: Registered
Posts: 119

Was thanked: 4 time(s) in 4 post(s)

Below you will find a basic C# code sample on how you can load in your DICOM then save it out to a JPEG2000 compression type which will greatly decrease the file size.

When doing this compression, you will be using the DicomJpeg2000Options structure. Once you have your options initialized, then you can begin setting the options for the new DICOM file.

There are two main enumerations that will be used in this process:


Once you have these enumerations set for the DicomJpeg2000Options you will need to give the options to the dataset itself.

Now you can use ChangeTransferSyntax to change the transfer syntax of the data set.

Finally, you can save the data set using the Save method.

With these setting I was able to compress a DICOM file from 854kb down to 36KB.


Code:

DicomEngine.Startup();
using (DicomDataSet ds = new DicomDataSet())
{
   //Load DICOM File 
   ds.Load(input, DicomDataSetLoadFlags.None);

   //Initialize J2K Options
   DicomJpeg2000Options options = ds.DefaultJpeg2000Options;

   //Set Options
   options.CompressionControl = DicomJpeg2000CompressionControl.Ratio;
   options.CompressionRatio = 50;

   //Add options to the dataset
   ds.Jpeg2000Options = options;

   //Change the transfer syntax to J22K
   ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.MinimizeJpegSize);

   //Save Dicom file
   ds.Save(dest, DicomDataSetSaveFlags.None);

   //Shut down the DICOM engine
   DicomEngine.Shutdown();
}

Edited by moderator Friday, December 29, 2017 8:51:29 AM(UTC)  | Reason: Changed subject to better reflect content

Nick Villalobos
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.040 seconds.