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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*=========================================================================
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.
=========================================================================*/
// We are required to call the package 'vtk' even though I (MM) would have preferred
// an import statement along the line of:
// import vtkgdcm.*;
import vtk.*;
/*
* Usage:
* export LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/xawt:.
* java -classpath `pwd`/vtkgdcm.jar:/usr/share/java/vtk.jar:. ReadSeriesIntoVTK
*/
public class ReadSeriesIntoVTK
{
static {
System.loadLibrary("vtkCommonJava");
System.loadLibrary("vtkFilteringJava");
System.loadLibrary("vtkIOJava");
System.loadLibrary("vtkImagingJava");
System.loadLibrary("vtkGraphicsJava");
System.loadLibrary("vtkgdcmJava");
try {
System.loadLibrary("vtkRenderingJava");
} catch (Throwable e) {
System.out.println("cannot load vtkHybrid, skipping...");
}
try {
System.loadLibrary("vtkHybridJava");
} catch (Throwable e) {
System.out.println("cannot load vtkHybrid, skipping...");
}
try {
System.loadLibrary("vtkVolumeRenderingJava");
} catch (Throwable e) {
System.out.println("cannot load vtkVolumeRendering, skipping...");
}
}
public static void main(String[] args)
{
vtkFileOutputWindow outWin = new vtkFileOutputWindow();
outWin.SetInstance(outWin);
outWin.SetFileName("MVSVTKViewer.log");
// See: http://review.source.kitware.com/#change,888
// vtkWrapJava does not handle static keyword
// String directory = vtkGDCMTesting.GetGDCMDataRoot();
vtkGDCMTesting t = new vtkGDCMTesting();
String directory = t.GetGDCMDataRoot();
String file0 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq0.dcm";
String file1 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq1.dcm";
String file2 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq2.dcm";
String file3 = directory + "/SIEMENS_MAGNETOM-12-MONO2-FileSeq3.dcm";
vtkStringArray s = new vtkStringArray();
System.out.println("adding : " + file0 );
s.InsertNextValue( file0 );
s.InsertNextValue( file1 );
s.InsertNextValue( file2 );
s.InsertNextValue( file3 );
vtkGDCMImageReader reader = new vtkGDCMImageReader();
reader.SetFileNames( s );
reader.Update();
System.out.println("Success reading: " + file0 );
vtkMetaImageWriter writer = new vtkMetaImageWriter();
writer.DebugOn();
writer.SetCompression( false );
writer.SetInputConnection( reader.GetOutputPort() );
writer.SetFileName( "ReadSeriesIntoVTK.mhd" );
writer.Write();
System.out.println("Success writing: " + writer.GetFileName() );
}
}
|