1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*
* This example will take in a DICOM file, and tries to decompress it (actually write it
* as ImplicitVRLittleEndian Transfer Syntax).
*
* Compilation:
* $ CLASSPATH=gdcm.jar javac ../../gdcm/Examples/Java/DecompressImage.java -d .
*
* Usage:
* $ LD_LIBRARY_PATH=. CLASSPATH=gdcm.jar:. java DecompressImage gdcmData/012345.002.050.dcm out.dcm
*/
import gdcm.*;
public class DecompressImage
{
public static void main(String[] args) throws Exception
{
String file1 = args[0];
String file2 = args[1];
ImageReader reader = new ImageReader();
reader.SetFileName( file1 );
boolean ret = reader.Read();
if( !ret )
{
throw new Exception("Could not read: " + file1 );
}
ImageChangeTransferSyntax change = new ImageChangeTransferSyntax();
change.SetTransferSyntax( new TransferSyntax(TransferSyntax.TSType.ImplicitVRLittleEndian) );
change.SetInput( reader.GetImage() );
if( !change.Change() )
{
throw new Exception("Could not change: " + file1 );
}
Image out = change.GetOutput();
System.out.println( out.toString() );
// Set the Source Application Entity Title
FileMetaInformation.SetSourceApplicationEntityTitle( "Just For Fun" );
ImageWriter writer = new ImageWriter();
writer.SetFileName( file2 );
writer.SetFile( reader.GetFile() );
writer.SetImage( out );
ret = writer.Write();
if( !ret )
{
throw new Exception("Could not write: " + file2 );
}
}
}
|