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() );
writer.Write();
return 0;
}
}
vtkGDCMImageReader
Definition vtkGDCMImageReader.h:105
vtkGDCMImageReader::New
static vtkGDCMImageReader * New()
vtkGDCMImageWriter
Definition vtkGDCMImageWriter.h:50
vtkGDCMImageWriter::Write
virtual void Write()
vtkGDCMImageWriter::New
static vtkGDCMImageWriter * New()
vtkGDCMImageWriter::SetMedicalImageProperties
virtual void SetMedicalImageProperties(vtkMedicalImageProperties *)
vtkGDCMImageWriter::SetDirectionCosines
virtual void SetDirectionCosines(vtkMatrix4x4 *matrix)