GDCM 2.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

HelloVTKWorld.cs
/*=========================================================================
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.
=========================================================================*/
using vtkgdcm;
/*
* This test only test the SWIG/VTK part, you do not need Activiz
*/
public class HelloVTKWorld
{
public static int Main(string[] args)
{
string filename = args[0];
vtkGDCMImageReader reader = vtkGDCMImageReader.New();
reader.SetFileName( filename );
reader.Update();
vtkMedicalImageProperties prop = reader.GetMedicalImageProperties();
System.Console.WriteLine( prop.GetPatientName() ); //
if( reader.GetImageFormat() == vtkgdcm.vtkgdcm.VTK_LUMINANCE ) // MONOCHROME2
{
System.Console.WriteLine( "Image is MONOCHROME2" ); //
}
// Just for fun, invert the direction cosines, output should reflect that:
vtkMatrix4x4 dircos = reader.GetDirectionCosines();
dircos.Invert();
string outfilename = args[1];
vtkGDCMImageWriter writer = vtkGDCMImageWriter.New();
writer.SetMedicalImageProperties( reader.GetMedicalImageProperties() );
writer.SetDirectionCosines( dircos );
writer.SetShift( reader.GetShift() );
writer.SetScale( reader.GetScale() );
writer.SetImageFormat( reader.GetImageFormat() );
writer.SetFileName( outfilename );
//writer.SetInputConnection( reader.GetOutputPort() ); // new
writer.SetInput( reader.GetOutput() ); // old
writer.Write();
return 0;
}
}