Dcm4che3 Decompressor wont decompress jpegs

262 views
Skip to first unread message

stephen fogarasi

unread,
Jun 29, 2016, 5:29:59 PM6/29/16
to dcm...@googlegroups.com
Im kind of following the dcm2dcm example. I want to get access to the pixel data for some image processing.
Im reading some Jpeg lossless (1.2.840.10008.1.2.4.70) images with dcm4che3 but when it gets to the line in class Decompressor

...

this.decompressor = ImageReaderFactory.getImageReader(param);

...


it throws a runtime exception :

     No Image Reader for format: jpeg registered

Im watching it iterate through the ImageReaderSpi map in the ImageReaderFactory, but there isnt a JPEG reader in the list. Am I missing something ?


Nothing in the dcm2dcm that I can see is registering reader types.


Here is a code fragment from my stuff :


private byte[] extractCompressedFragments ( Object pixelData, Attributes dataset ){
        byte[] uncompressedPixelData = null;
       
     if ( pixelData != null ) {
      DicomImage parentImage = getParentImage();
      if ( parentImage != null ) {
   
       Attributes fmi = parentImage.dicomMetaInformation;
       String tsuid = fmi.getString( Tag.TransferSyntaxUID );
       TransferSyntaxType tstype = TransferSyntaxType.forUID ( tsuid);
       
       if ( tstype.isPixeldataEncapsulated() ) {
        logger.info( "pixel data is encapsulated"); 
        
        if (pixelData instanceof Fragments) {
         logger.info( "its Fragments" );

         Fragments pixeldataFragments = (Fragments) pixelData;
         int numFragments = pixeldataFragments.size();
         /*  it said there are 2 */         
         try {

           
           if ( Decompressor.decompress( dataset, tsuid ) ) {
           uncompressedPixelData = dataset.getBytes(Tag.PixelData);
           }
         } catch ( IOException e ) {
          logger.error ( "IOException Thrown : " + e.getMessage() );
         } catch ( RuntimeException e ) {
          logger.error ( "RuntimeException Thrown : " + e.getMessage() );
         } catch ( Exception e ) {
          logger.error( "General Exception thrown : " + e.getMessage() );
         }
        }
     
       } else {
        logger.info( "its no encapsulate not jpeg ! ");
       }                  
      }  
     } 
    
     return uncompressedPixelData;
 }



Anyone know what I am doing wrong, or what would be a better way to get the uncompressed pixel data ?


thanks


stephen fogarasi

unread,
Jun 30, 2016, 4:19:47 PM6/30/16
to dcm...@googlegroups.com

an addendum, found a reason (and solution) for the problem !!!


reading a bit more in the forums, it seems that getting jpeg compression/decompression to work with the dcm4che3 toolkit is not that straightforward, and Im wondering if I have the best solution (Im running on windows 7 by the way)

From what I gathered (and please correct me on anything wrong)
compression/decompression is handled with jai-imagio native routines - and these dlls are only available in 32 editions (they are old),
So I rebuilt my application with the 32 bit java jdks 
I installed the native JAI dlls - THIS IS REAL IMPORTANT
I used the maven poms that brought down the dcm4che3 poms, nothing changed there 
(I even added the JAI dependency to the pom, THAT WAS A MISTAKE, DONT DO THAT)

And with that I got bunch of JPEG readers and the above code works (I think, still have to see the pixel content) !

Im not really sure how that part of the toolkit is working, can anyone provide some technical walkthrough ?

Anyone have some helpful ideas on deploying an application to support compression now? Thanks in advance.

Reply all
Reply to author
Forward
0 new messages