Exemple #1
0
    public static int Main(string[] args)
    {
        string filename = args[0];

        vtkGDCMImageReader reader = vtkGDCMImageReader.New();
        vtkStringArray     array  = vtkStringArray.New();

        array.InsertNextValue(filename);

        reader.SetFileNames(array);
        reader.Update();

        //System.Console.Write(reader.GetOutput());

        vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();

        vtkImageViewer2 viewer = vtkImageViewer2.New();

        viewer.SetInput(reader.GetOutput());
        viewer.SetupInteractor(iren);
        viewer.SetSize(600, 600);
        viewer.Render();

        iren.Initialize();
        iren.Start();

        return(0);
    }
Exemple #2
0
    public static int Main(string[] args)
    {
        string filename = args[0];

        vtkGDCMImageReader reader = new vtkGDCMImageReader();
        vtkStringArray array = vtkStringArray.New();
        array.InsertNextValue(filename);

        reader.SetFileNames(array);
        reader.Update();

        //System.Console.Write(reader.GetOutput());

        vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();

        vtkImageViewer viewer = vtkImageViewer.New();
        viewer.SetInput(reader.GetOutput());
        viewer.SetupInteractor(iren);
        viewer.SetSize(600, 600);
        viewer.Render();

        iren.Initialize();
        iren.Start();

        return 0;
    }
Exemple #3
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);
    }
Exemple #4
0
    public static int ProcessOneMHDMD5(string filename)
    {
        vtkGDCMImageReader reader = vtkGDCMImageReader.New();

        reader.FileLowerLeftOn();
        reader.DebugOff();
        int canread = reader.CanReadFile(filename);

        if (canread == 0)
        {
            string refms = gdcm.Testing.GetMediaStorageFromFile(filename);
            if (gdcm.MediaStorage.IsImage(gdcm.MediaStorage.GetMSType(refms)))
            {
                System.Console.Write("Problem with file: " + filename + "\n");
                return(1);
            }
            // not an image
            return(0);
        }

        reader.SetFileName(filename);
        reader.Update();

        // System.Console.Write(reader.GetOutput());

        vtkMetaImageWriter writer = vtkMetaImageWriter.New();

        writer.SetCompression(false);
        writer.SetInput(reader.GetOutput());
        string subdir = "MetaImageMD5Activiz";
        string tmpdir = gdcm.Testing.GetTempDirectory(subdir);

        if (!gdcm.PosixEmulation.FileIsDirectory(tmpdir))
        {
            gdcm.PosixEmulation.MakeDirectory(tmpdir);
        }
        string mhdfile = gdcm.Testing.GetTempFilename(filename, subdir);

        string rawfile = mhdfile;

        mhdfile += ".mhd";
        rawfile += ".raw";
        writer.SetFileName(mhdfile);
        writer.Write();

        string digestmhd = gdcm.Testing.ComputeFileMD5(mhdfile);
        string digestraw = gdcm.Testing.ComputeFileMD5(rawfile);

        string mhdref = vtkGDCMTesting.GetMHDMD5FromFile(filename);
        string rawref = vtkGDCMTesting.GetRAWMD5FromFile(filename);

        if (mhdref != digestmhd)
        {
            System.Console.Write("Problem with mhd file: " + filename + "\n");
            System.Console.Write(digestmhd);
            System.Console.Write("\n");
            System.Console.Write(mhdref);
            System.Console.Write("\n");
            return(1);
        }
        if (rawref != digestraw)
        {
            System.Console.Write("Problem with raw file: " + filename + "\n");
            System.Console.Write(digestraw);
            System.Console.Write("\n");
            System.Console.Write(rawref);
            System.Console.Write("\n");
            return(1);
        }

        return(0);
    }
Exemple #5
0
    public static int Main(string[] args)
    {
        vtkTesting testHelper = vtkTesting.New();

        for (int cc = 0; cc < args.Length; cc++)
        {
            //testHelper.AddArguments(argc,const_cast<const char **>(argv));
            //System.Console.Write( "args: " + args[cc] + "\n" );
            testHelper.AddArgument(args[cc]);
        }
        if (testHelper.IsFlagSpecified("-D") != 0)
        {
            string VTK_DATA_ROOT = vtkGDCMTesting.GetVTKDataRoot();
            if (VTK_DATA_ROOT != null)
            {
                //System.Console.Write( "VTK_DATA_ROOT: " + VTK_DATA_ROOT  + "\n" );
                testHelper.SetDataRoot(VTK_DATA_ROOT);
                testHelper.AddArgument("-D");
                testHelper.AddArgument(VTK_DATA_ROOT);
            }
        }

        string dataRoot = testHelper.GetDataRoot();
        string filename = dataRoot;

        filename += "/Data/mr.001";

        vtkDirectory dir = vtkDirectory.New();

        if (dir.FileIsDirectory(dataRoot) == 0)
        {
            filename = vtkGDCMTesting.GetGDCMDataRoot() + "/test.acr";
        }
        //System.Console.Write( "dataRoot: " + dataRoot + "\n" );
        System.Console.Write("filename being used is: " + filename + "\n");

        vtkGDCMImageReader reader = vtkGDCMImageReader.New();
        vtkStringArray     array  = vtkStringArray.New();

        array.InsertNextValue(filename);
        reader.SetFileNames(array);
        reader.Update();

        System.Console.Write(reader.GetOutput());

        vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New();

        vtkRenderer     ren1   = vtkRenderer.New();
        vtkRenderWindow renWin = vtkRenderWindow.New();

        renWin.AddRenderer(ren1);

        vtkImageActor actor = vtkImageActor.New();

        vtkImageMapToWindowLevelColors coronalColors = vtkImageMapToWindowLevelColors.New();

        coronalColors.SetInput(reader.GetOutput());

        actor.SetInput(coronalColors.GetOutput());

        ren1.AddActor(actor);
        iren.SetRenderWindow(renWin);

        iren.Initialize();

        renWin.Render();

        int retVal = testHelper.IsInteractiveModeSpecified();

        if (retVal != 0)
        {
            iren.Start();
        }

        return(0);
    }