Exemplo n.º 1
0
    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);
    }