Esempio n. 1
0
    public static int Main(string[] args)
    {
        string VTK_DATA_ROOT = vtkGDCMTesting.GetVTKDataRoot();

        vtkVolume16Reader reader = vtkVolume16Reader.New();

        reader.SetDataDimensions(64, 64);
        reader.SetDataByteOrderToLittleEndian();
        reader.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter");
        reader.SetImageRange(1, 93);
        reader.SetDataSpacing(3.2, 3.2, 1.5);

        vtkImageCast cast = vtkImageCast.New();

        cast.SetInputConnection(reader.GetOutputPort());
        cast.SetOutputScalarTypeToUnsignedChar();

        // By default this is creating a Multiframe Grayscale Word Secondary Capture Image Storage
        vtkGDCMImageWriter writer = vtkGDCMImageWriter.New();

        writer.SetFileName("headsq.dcm");
        writer.SetInputConnection(reader.GetOutputPort());
        // cast -> Multiframe Grayscale Byte Secondary Capture Image Storage
        // writer.SetInputConnection( cast.GetOutputPort() );
        writer.SetFileDimensionality(3);
        writer.Write();

        return(0);
    }
Esempio n. 2
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());
        writer.Write();

        return(0);
    }