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); }
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; }
public static int Main(string[] args) { string filename = args[0]; string outfilename = args[1]; // Step 1. Test SWIG -> Activiz vtkGDCMImageReader reader = vtkGDCMImageReader.New(); reader.SetFileName(filename); //reader.Update(); // DO NOT call Update to check pipeline execution Kitware.VTK.vtkImageData imgout = ConnectSWIGToActiviz(reader.GetOutput()); System.Console.WriteLine(imgout.ToString()); // not initialized as expected vtkPNGWriter writer = new vtkPNGWriter(); writer.SetInput(imgout); writer.SetFileName(outfilename); writer.Write(); // Step 2. Test Activiz -> SWIG vtkPNGReader bmpreader = new vtkPNGReader(); bmpreader.SetFileName(outfilename); //bmpreader.Update(); // DO NOT update to check pipeline execution System.Console.WriteLine(bmpreader.GetOutput().ToString()); // not initialized as expected vtkgdcm.vtkImageData imgout2 = ConnectActivizToSWIG(bmpreader.GetOutput()); System.Console.WriteLine(imgout2.ToString()); // not initialized as expected Kitware.VTK.vtkMedicalImageProperties prop = new Kitware.VTK.vtkMedicalImageProperties(); prop.SetModality("MR"); string outfilename2 = args[2]; vtkGDCMImageWriter writer2 = vtkGDCMImageWriter.New(); writer2.SetMedicalImageProperties(prop.CastToActiviz()); writer2.SetFileName(outfilename2); writer2.SetInput(imgout2); writer2.Write(); return(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); }
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); }
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); }