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 : Tuesday, October 12, 2010 1:29:21 AM(UTC)

maddy19  
maddy19

Groups: Registered
Posts: 3


Hi,
 I am new to Leadtools.  I want to
            1.compress a DICOM raw filw to JPEG lossless  and
            2. decompress different Compressed DICOM files (such as JPEGLossless, JPEGlossy, JPEG2000, JPEG2000 losses, RLE etc.)
                 to DICOM raw file.
I tried to used the method ChangeTransferSyntax which only changes the any transfered syntax to desired one. However this method does not compress any file in pixel. Thus a raw dicom file compressed is just any raw filw with changed tranfer syntax file.

I saw some example for using StartCompress, Compress, StopCompress for Compression
                                   ( http://www.leadtools.com...ompress.html   )
                                   and     StartDecompress, Decompress, StopDecompress for Decompression of Tiff file
 (http://www.leadtools.com/help/leadtools/v15/DH/CO/Leadtools.Codecs~Leadtools.Codecs.RasterCodecs~Decompress(Object,Byte[],Int32,Int32,Int32,Int32,Int32,Int32,CodecsDecompressDataFlags).html)

I tried the above code however there are some parameters which i am not sure about JPEG

My problems are as follows

For Compression to Jpeg Lossless:
1. what will be the following line specialythe bold ones
     codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.QualityAndSize;
2. what is the CodecsCompression in the following line
    codecs.StartCompress(
            image.Width,
            image.Height,
            image.BitsPerPixel,
            image.Order,
            image.ViewPerspective,
            16 * lineBytes,
            outBuffer,
            0,
            outBuffer.Length,
            CodecsCompression.Cmp,
            MyCodecsCompressDataCallback);
  3. how do i call the MyCodecsCompressDatacallBack method. is it with an object of RasterCodecs
 
For Decompression to DICOM raw:
1. What will be the values for Raw dicom for the following bold ones
             CodecsStartDecompressOptions options = CodecsStartDecompressOptions.Empty;
         options.DataType = CodecsStartDecompressDataType.Strips;
         options.Format = RasterImageFormat.RawPackBits; // specially this one
         options.Width = imageInfo.Width;
         options.Height = imageInfo.Height;
         options.BitsPerPixel = imageInfo.BitsPerPixel;
         options.ViewPerspective = imageInfo.ViewPerspective;
         options.RawOrder = imageInfo.Order;
         options.LoadOrder = CodecsLoadByteOrder.BgrOrGray;  // specially this one
         options.XResolution = imageInfo.XResolution;
         options.YResolution = imageInfo.YResolution;
         options.TiffPhotometricInterpretation = CodecsTiffPhotometricInterpretation.Rgb; // do i need this line as it is for tiff file format?
when i remove it i get error.
2. with what saving option can i save my output file for DICOM raw
codecs.Save(image, destRawDicomFilename, RasterImageFormat.Raw, 24);
       
I really appreciate any help

Thanks in advance
 

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.

#2 Posted : Tuesday, October 12, 2010 6:10:48 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

You don't need to use the low level compression functions.
If you want to convert a Dicom Dataset to uncompressed, you can use the following code:
+----------+
Leadtools.Dicom.DicomEngine.Startup();

Leadtools.Dicom.DicomDataSet m_DS = new Leadtools.Dicom.DicomDataSet();

m_DS.Load(@"c:\DICOM\IMAGE2.dcm", Leadtools.Dicom.DicomDataSetLoadFlags.None);

m_DS.ChangeTransferSyntax(Leadtools.Dicom.DicomUidType.ExplicitVRLittleEndian, 2, Leadtools.Dicom.ChangeTransferSyntaxFlags.None);

m_DS.Save(@"c:\DICOM\DicomExplicitVRLittleEndian.dcm", Leadtools.Dicom.DicomDataSetSaveFlags.None);

Leadtools.Dicom.DicomEngine.Shutdown();
+----------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Tuesday, October 12, 2010 10:00:54 PM(UTC)

maddy19  
maddy19

Groups: Registered
Posts: 3


Hi, Thanks for the reply.
Now I can decompress a JPEGLossless file.
I believe it will work for all compressed dicom files as well?
I tried to implement the same logic for dicom JPEGlossless compression.
below is my code:
Leadtools.Dicom.DicomEngine.Startup();

Leadtools.Dicom.DicomDataSet m_DS = new Leadtools.Dicom.DicomDataSet();

m_DS.Load(@"c:\DICOM\IMAGE2.dcm", Leadtools.Dicom.DicomDataSetLoadFlags.None);

m_DS.ChangeTransferSyntax(Leadtools.Dicom.DicomUidType.JPEGLosslessNonhier14,CompressionQuality , Leadtools.Dicom.ChangeTransferSyntaxFlags.None);

m_DS.Save(@"c:\DICOM\DicomJPEGlossless.dcm", Leadtools.Dicom.DicomDataSetSaveFlags.None);

Leadtools.Dicom.DicomEngine.Shutdown();

where CompressionQuality = compression quality (0-255)

I able to compress the file with jpeg lossless format with above code and can view the compressed file using a viewer.

Just want to be clear if i am setting the parameter correctly for ChangeTransferSyntax and Save methods here?
I read in the forum for JPEG lossless the quality factor should be 0.
So if i am saving it to some value between 0-255, am i doing correct for JPEG lossless or not?
My aim is to reduce the dicom file size to great extend with compression.


Thanks in advance
 
#4 Posted : Wednesday, October 13, 2010 5:31:54 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

The quality factor values from 2 to 255 are only for LOSSY compression.

Since you want to save lossless Jpeg, the quality factor should not have any effect on the result images.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
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.087 seconds.