示例#1
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);
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestTIFFReader(String [] argv)
    {
        //Prefix Content is: ""

          // Image pipeline[]
          createReader = new vtkImageReader2Factory();
          reader = vtkImageReader2Factory.CreateImageReader2((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
          // "beach.tif" image contains ORIENTATION tag which is []
          // ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF []
          // reader parses this tag and sets the internal TIFF image []
          // orientation accordingly.  To overwrite this orientation with a vtk[]
          // convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke[]
          // SetOrientationType method with parameter value of 4.[]
          ((vtkTIFFReader)reader).SetOrientationType(4);
          viewer = new vtkImageViewer();
          viewer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          viewer.SetColorWindow((double)256);
          viewer.SetColorLevel((double)127.5);
          //make interface[]
          viewer.Render();
          //reader.Unregister(['UnRegister', 'viewer']) Skipped

        //deleteAllVTKObjects();
    }
示例#3
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestTIFFReader(String [] argv)
    {
        //Prefix Content is: ""

        // Image pipeline[]
        createReader = new vtkImageReader2Factory();
        reader       = vtkImageReader2Factory.CreateImageReader2((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
        reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
        // "beach.tif" image contains ORIENTATION tag which is []
        // ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF []
        // reader parses this tag and sets the internal TIFF image []
        // orientation accordingly.  To overwrite this orientation with a vtk[]
        // convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke[]
        // SetOrientationType method with parameter value of 4.[]
        ((vtkTIFFReader)reader).SetOrientationType(4);
        viewer = new vtkImageViewer();
        viewer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        viewer.SetColorWindow((double)256);
        viewer.SetColorLevel((double)127.5);
        //make interface[]
        viewer.Render();
        //reader.Unregister(['UnRegister', 'viewer']) Skipped

//deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestPImageWriter(String [] argv)
    {
        //Prefix Content is: ""

        // Image pipeline[]
        image1 = new vtkTIFFReader();
        image1.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
        // "beach.tif" image contains ORIENTATION tag which is []
        // ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF []
        // reader parses this tag and sets the internal TIFF image []
        // orientation accordingly.  To overwrite this orientation with a vtk[]
        // convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke[]
        // SetOrientationType method with parameter value of 4.[]
        image1.SetOrientationType((uint)4);
        image1.Update();
        //[]
        // If the current directory is writable, then test the witers[]
        //[]
        try
        {
            channel       = new StreamWriter("test.tmp");
            tryCatchError = "NOERROR";
        }
        catch (Exception)
        { tryCatchError = "ERROR"; }

        if (tryCatchError.Equals("NOERROR"))
        {
            channel.Close();
            File.Delete("test.tmp");
            piw = new vtkPImageWriter();
            piw.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            piw.SetFileName((string)"piw.raw");
            piw.SetMemoryLimit((uint)1);
            piw.Write();
            File.Delete("piw.raw");
        }


        viewer = new vtkImageViewer();
        viewer.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
        viewer.SetColorWindow((double)255);
        viewer.SetColorLevel((double)127.5);
        viewer.Render();

//deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestPImageWriter(String [] argv)
    {
        //Prefix Content is: ""

          // Image pipeline[]
          image1 = new vtkTIFFReader();
          image1.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
          // "beach.tif" image contains ORIENTATION tag which is []
          // ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF []
          // reader parses this tag and sets the internal TIFF image []
          // orientation accordingly.  To overwrite this orientation with a vtk[]
          // convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke[]
          // SetOrientationType method with parameter value of 4.[]
          image1.SetOrientationType((uint)4);
          image1.Update();
          //[]
          // If the current directory is writable, then test the witers[]
          //[]
          try
          {
          channel = new StreamWriter("test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("test.tmp");
          piw = new vtkPImageWriter();
          piw.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          piw.SetFileName((string)"piw.raw");
          piw.SetMemoryLimit((uint)1);
          piw.Write();
          File.Delete("piw.raw");
        }

          viewer = new vtkImageViewer();
          viewer.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          viewer.SetColorWindow((double)255);
          viewer.SetColorLevel((double)127.5);
          viewer.Render();

        //deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestImageStreamer(String [] argv)
    {
        //Prefix Content is: ""

        reader = new vtkImageReader();
        reader.ReleaseDataFlagOff();
        reader.SetDataByteOrderToLittleEndian();
        reader.SetDataExtent((int)0, (int)63, (int)0, (int)63, (int)1, (int)93);
        reader.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
        reader.SetDataMask((int)0x7fff);
        rangeStart = 0.0;
        rangeEnd   = 0.2;
        LUT        = new vtkLookupTable();
        LUT.SetTableRange((double)0, (double)1800);
        LUT.SetSaturationRange((double)1, (double)1);
        LUT.SetHueRange((double)rangeStart, (double)rangeEnd);
        LUT.SetValueRange((double)1, (double)1);
        LUT.SetAlphaRange((double)1, (double)1);
        LUT.Build();
        // added these unused default arguments so that the prototype[]
        // matches as required in python.[]
        //method moved
        mapToRGBA = new vtkImageMapToColors();
        mapToRGBA.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        mapToRGBA.SetOutputFormatToRGBA();
        mapToRGBA.SetLookupTable((vtkScalarsToColors)LUT);

        mapToRGBA.EndEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(changeLUT_Command.Execute);

        streamer = new vtkMemoryLimitImageDataStreamer();
        streamer.SetInputConnection((vtkAlgorithmOutput)mapToRGBA.GetOutputPort());
        streamer.SetMemoryLimit((uint)100);
        streamer.UpdateWholeExtent();
        // set the window/level to 255.0/127.5 to view full range[]
        viewer = new vtkImageViewer();
        viewer.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
        viewer.SetColorWindow((double)255.0);
        viewer.SetColorLevel((double)127.5);
        viewer.SetZSlice((int)50);
        viewer.Render();

//deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestImageStreamer(String [] argv)
    {
        //Prefix Content is: ""

          reader = new vtkImageReader();
          reader.ReleaseDataFlagOff();
          reader.SetDataByteOrderToLittleEndian();
          reader.SetDataExtent((int)0,(int)63,(int)0,(int)63,(int)1,(int)93);
          reader.SetFilePrefix((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/headsq/quarter");
          reader.SetDataMask((int)0x7fff);
          rangeStart = 0.0;
          rangeEnd = 0.2;
          LUT = new vtkLookupTable();
          LUT.SetTableRange((double)0,(double)1800);
          LUT.SetSaturationRange((double)1,(double)1);
          LUT.SetHueRange((double)rangeStart,(double)rangeEnd);
          LUT.SetValueRange((double)1,(double)1);
          LUT.SetAlphaRange((double)1,(double)1);
          LUT.Build();
          // added these unused default arguments so that the prototype[]
          // matches as required in python.[]
          //method moved
          mapToRGBA = new vtkImageMapToColors();
          mapToRGBA.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          mapToRGBA.SetOutputFormatToRGBA();
          mapToRGBA.SetLookupTable((vtkScalarsToColors)LUT);

          mapToRGBA.EndEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler(changeLUT_Command.Execute);

          streamer = new vtkMemoryLimitImageDataStreamer();
          streamer.SetInputConnection((vtkAlgorithmOutput)mapToRGBA.GetOutputPort());
          streamer.SetMemoryLimit((uint)100);
          streamer.UpdateWholeExtent();
          // set the window/level to 255.0/127.5 to view full range[]
          viewer = new vtkImageViewer();
          viewer.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort());
          viewer.SetColorWindow((double)255.0);
          viewer.SetColorLevel((double)127.5);
          viewer.SetZSlice((int)50);
          viewer.Render();

        //deleteAllVTKObjects();
    }
示例#8
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setviewer(vtkImageViewer toSet)
 {
     viewer = toSet;
 }
示例#9
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVcursor3D(String [] argv)
    {
        //Prefix Content is: ""

        // This little example shows how a cursor can be created in []
        // image viewers, and renderers.  The standard TkImageViewerWidget and[]
        // TkRenderWidget bindings are used.  There is a new binding:[]
        // middle button in the image viewer sets the position of the cursor.  []
        // First we include the VTK Tcl packages which will make available []
        // all of the vtk commands to Tcl[]
        // Global values[]
        CURSOR_X    = 20;
        CURSOR_Y    = 20;
        CURSOR_Z    = 20;
        IMAGE_MAG_X = 4;
        IMAGE_MAG_Y = 4;
        IMAGE_MAG_Z = 1;
        // Pipeline stuff[]
        reader = new vtkSLCReader();
        reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/neghip.slc");
        // Cursor stuff[]
        magnify = new vtkImageMagnify();
        magnify.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        magnify.SetMagnificationFactors((int)IMAGE_MAG_X, (int)IMAGE_MAG_Y, (int)IMAGE_MAG_Z);
        image_cursor = new vtkImageCursor3D();
        image_cursor.SetInputConnection((vtkAlgorithmOutput)magnify.GetOutputPort());
        image_cursor.SetCursorPosition((double)CURSOR_X * IMAGE_MAG_X, (double)CURSOR_Y * IMAGE_MAG_Y, (double)CURSOR_Z * IMAGE_MAG_Z);
        image_cursor.SetCursorValue((double)255);
        image_cursor.SetCursorRadius((int)50 * IMAGE_MAG_X);
        axes = new vtkAxes();
        axes.SymmetricOn();
        axes.SetOrigin((double)CURSOR_X, (double)CURSOR_Y, (double)CURSOR_Z);
        axes.SetScaleFactor((double)50.0);
        axes_mapper = vtkPolyDataMapper.New();
        axes_mapper.SetInputConnection((vtkAlgorithmOutput)axes.GetOutputPort());
        axesActor = new vtkActor();
        axesActor.SetMapper((vtkMapper)axes_mapper);
        axesActor.GetProperty().SetAmbient((double)0.5);
        // Image viewer stuff[]
        viewer = new vtkImageViewer();
        viewer.SetInputConnection((vtkAlgorithmOutput)image_cursor.GetOutputPort());
        viewer.SetZSlice((int)CURSOR_Z * IMAGE_MAG_Z);
        viewer.SetColorWindow((double)256);
        viewer.SetColorLevel((double)128);
        //method moved
        //method moved
        //method moved
        // Create transfer functions for opacity and color[]
        opacity_transfer_function = new vtkPiecewiseFunction();
        opacity_transfer_function.AddPoint((double)20, (double)0.0);
        opacity_transfer_function.AddPoint((double)255, (double)0.2);
        color_transfer_function = new vtkColorTransferFunction();
        color_transfer_function.AddRGBPoint((double)0, (double)0, (double)0, (double)0);
        color_transfer_function.AddRGBPoint((double)64, (double)1, (double)0, (double)0);
        color_transfer_function.AddRGBPoint((double)128, (double)0, (double)0, (double)1);
        color_transfer_function.AddRGBPoint((double)192, (double)0, (double)1, (double)0);
        color_transfer_function.AddRGBPoint((double)255, (double)0, (double).2, (double)0);
        // Create properties, mappers, volume actors, and ray cast function[]
        volume_property = new vtkVolumeProperty();
        volume_property.SetColor((vtkColorTransferFunction)color_transfer_function);
        volume_property.SetScalarOpacity((vtkPiecewiseFunction)opacity_transfer_function);
        composite_function = new vtkVolumeRayCastCompositeFunction();
        volume_mapper      = new vtkVolumeRayCastMapper();
        volume_mapper.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        volume_mapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)composite_function);
        volume = new vtkVolume();
        volume.SetMapper((vtkAbstractVolumeMapper)volume_mapper);
        volume.SetProperty((vtkVolumeProperty)volume_property);
        // Create outline[]
        outline = new vtkOutlineFilter();
        outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
        outline_mapper = vtkPolyDataMapper.New();
        outline_mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
        outlineActor = new vtkActor();
        outlineActor.SetMapper((vtkMapper)outline_mapper);
        outlineActor.GetProperty().SetColor((double)1, (double)1, (double)1);
        // Create the renderer[]
        ren1 = vtkRenderer.New();
        ren1.AddActor((vtkProp)axesActor);
        ren1.AddVolume((vtkProp)volume);
        ren1.SetBackground((double)0.1, (double)0.2, (double)0.4);
        renWin2 = vtkRenderWindow.New();
        renWin2.AddRenderer((vtkRenderer)ren1);
        renWin2.SetSize((int)256, (int)256);
        // Create the GUI: two renderer widgets and a quit button[]
        //tk window skipped..
        // Set the window manager (wm command) so that it registers a[]
        // command to handle the WM_DELETE_WINDOW protocal request. This[]
        // request is triggered when the widget is closed using the standard[]
        // window manager icons or buttons. In this case the exit callback[]
        // will be called and it will free up any objects we created then exit[]
        // the application.[]
        // Help label, frame and quit button[]
        //tk window skipped..
        //tk window skipped..
        //tk window skipped..

//deleteAllVTKObjects();
    }
示例#10
0
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVcursor3D(String [] argv)
    {
        //Prefix Content is: ""

          // This little example shows how a cursor can be created in []
          // image viewers, and renderers.  The standard TkImageViewerWidget and[]
          // TkRenderWidget bindings are used.  There is a new binding:[]
          // middle button in the image viewer sets the position of the cursor.  []
          // First we include the VTK Tcl packages which will make available []
          // all of the vtk commands to Tcl[]
          // Global values[]
          CURSOR_X = 20;
          CURSOR_Y = 20;
          CURSOR_Z = 20;
          IMAGE_MAG_X = 4;
          IMAGE_MAG_Y = 4;
          IMAGE_MAG_Z = 1;
          // Pipeline stuff[]
          reader = new vtkSLCReader();
          reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/neghip.slc");
          // Cursor stuff[]
          magnify = new vtkImageMagnify();
          magnify.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          magnify.SetMagnificationFactors((int)IMAGE_MAG_X,(int)IMAGE_MAG_Y,(int)IMAGE_MAG_Z);
          image_cursor = new vtkImageCursor3D();
          image_cursor.SetInputConnection((vtkAlgorithmOutput)magnify.GetOutputPort());
          image_cursor.SetCursorPosition((double)CURSOR_X*IMAGE_MAG_X,(double)CURSOR_Y*IMAGE_MAG_Y,(double)CURSOR_Z*IMAGE_MAG_Z);
          image_cursor.SetCursorValue((double)255);
          image_cursor.SetCursorRadius((int)50*IMAGE_MAG_X);
          axes = new vtkAxes();
          axes.SymmetricOn();
          axes.SetOrigin((double)CURSOR_X,(double)CURSOR_Y,(double)CURSOR_Z);
          axes.SetScaleFactor((double)50.0);
          axes_mapper = vtkPolyDataMapper.New();
          axes_mapper.SetInputConnection((vtkAlgorithmOutput)axes.GetOutputPort());
          axesActor = new vtkActor();
          axesActor.SetMapper((vtkMapper)axes_mapper);
          axesActor.GetProperty().SetAmbient((double)0.5);
          // Image viewer stuff[]
          viewer = new vtkImageViewer();
          viewer.SetInputConnection((vtkAlgorithmOutput)image_cursor.GetOutputPort());
          viewer.SetZSlice((int)CURSOR_Z*IMAGE_MAG_Z);
          viewer.SetColorWindow((double)256);
          viewer.SetColorLevel((double)128);
          //method moved
          //method moved
          //method moved
          // Create transfer functions for opacity and color[]
          opacity_transfer_function = new vtkPiecewiseFunction();
          opacity_transfer_function.AddPoint((double)20,(double)0.0);
          opacity_transfer_function.AddPoint((double)255,(double)0.2);
          color_transfer_function = new vtkColorTransferFunction();
          color_transfer_function.AddRGBPoint((double)0,(double)0,(double)0,(double)0);
          color_transfer_function.AddRGBPoint((double)64,(double)1,(double)0,(double)0);
          color_transfer_function.AddRGBPoint((double)128,(double)0,(double)0,(double)1);
          color_transfer_function.AddRGBPoint((double)192,(double)0,(double)1,(double)0);
          color_transfer_function.AddRGBPoint((double)255,(double)0,(double).2,(double)0);
          // Create properties, mappers, volume actors, and ray cast function[]
          volume_property = new vtkVolumeProperty();
          volume_property.SetColor((vtkColorTransferFunction)color_transfer_function);
          volume_property.SetScalarOpacity((vtkPiecewiseFunction)opacity_transfer_function);
          composite_function = new vtkVolumeRayCastCompositeFunction();
          volume_mapper = new vtkVolumeRayCastMapper();
          volume_mapper.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          volume_mapper.SetVolumeRayCastFunction((vtkVolumeRayCastFunction)composite_function);
          volume = new vtkVolume();
          volume.SetMapper((vtkAbstractVolumeMapper)volume_mapper);
          volume.SetProperty((vtkVolumeProperty)volume_property);
          // Create outline[]
          outline = new vtkOutlineFilter();
          outline.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort());
          outline_mapper = vtkPolyDataMapper.New();
          outline_mapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort());
          outlineActor = new vtkActor();
          outlineActor.SetMapper((vtkMapper)outline_mapper);
          outlineActor.GetProperty().SetColor((double)1,(double)1,(double)1);
          // Create the renderer[]
          ren1 = vtkRenderer.New();
          ren1.AddActor((vtkProp)axesActor);
          ren1.AddVolume((vtkProp)volume);
          ren1.SetBackground((double)0.1,(double)0.2,(double)0.4);
          renWin2 = vtkRenderWindow.New();
          renWin2.AddRenderer((vtkRenderer)ren1);
          renWin2.SetSize((int)256,(int)256);
          // Create the GUI: two renderer widgets and a quit button[]
          //tk window skipped..
          // Set the window manager (wm command) so that it registers a[]
          // command to handle the WM_DELETE_WINDOW protocal request. This[]
          // request is triggered when the widget is closed using the standard[]
          // window manager icons or buttons. In this case the exit callback[]
          // will be called and it will free up any objects we created then exit[]
          // the application.[]
          // Help label, frame and quit button[]
          //tk window skipped..
          //tk window skipped..
          //tk window skipped..

        //deleteAllVTKObjects();
    }
示例#11
0
 ///<summary> A Set Method for Static Variables </summary>
 public static void Setviewer(vtkImageViewer toSet)
 {
     viewer = toSet;
 }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestImageWriters(String [] argv)
    {
        //Prefix Content is: ""

        // Image pipeline[]
        image1 = new vtkTIFFReader();
        image1.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
        // "beach.tif" image contains ORIENTATION tag which is []
        // ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF []
        // reader parses this tag and sets the internal TIFF image []
        // orientation accordingly.  To overwrite this orientation with a vtk[]
        // convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke[]
        // SetOrientationType method with parameter value of 4.[]
        image1.SetOrientationType((uint)4);
        image1.Update();
        sp = new vtkStructuredPoints();
        sp.SetDimensions(image1.GetOutput().GetDimensions()[0], image1.GetOutput().GetDimensions()[1], image1.GetOutput().GetDimensions()[2]);
        sp.SetExtent(
            image1.GetOutput().GetExtent()[0],
            image1.GetOutput().GetExtent()[1],
            image1.GetOutput().GetExtent()[2],
            image1.GetOutput().GetExtent()[3],
            image1.GetOutput().GetExtent()[4],
            image1.GetOutput().GetExtent()[5]);
        //sp.SetScalarType((int)image1.GetOutput().GetScalarType());
        //sp.SetNumberOfScalarComponents((int)image1.GetOutput().GetNumberOfScalarComponents());
        vtkDataObject.SetPointDataActiveScalarInfo(sp.GetInformation(), (int)image1.GetOutput().GetScalarType(), (int)image1.GetOutput().GetNumberOfScalarComponents());

        sp.GetPointData().SetScalars((vtkDataArray)image1.GetOutput().GetPointData().GetScalars());
        luminance = new vtkImageLuminance();
        luminance.SetInputData((vtkDataObject)sp);
        //[]
        // write to the temp directory if possible, otherwise use .[]
        //[]
        dir = ".";
        dir = TclToCsScriptTestDriver.GetTempDirectory();


        // make sure it is writeable first[]
        try
        {
            channel       = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
            tryCatchError = "NOERROR";
        }
        catch (Exception)
        { tryCatchError = "ERROR"; }

        if (tryCatchError.Equals("NOERROR"))
        {
            channel.Close();
            File.Delete("" + (dir.ToString()) + "/test.tmp");
            tiff1 = new vtkTIFFWriter();
            tiff1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            tiff1.SetFileName((string)"" + (dir.ToString()) + "/tiff1.tif");
            tiff2 = new vtkTIFFWriter();
            tiff2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
            tiff2.SetFileName((string)"" + (dir.ToString()) + "/tiff2.tif");
            bmp1 = new vtkBMPWriter();
            bmp1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            bmp1.SetFileName((string)"" + (dir.ToString()) + "/bmp1.bmp");
            bmp2 = new vtkBMPWriter();
            bmp2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
            bmp2.SetFileName((string)"" + (dir.ToString()) + "/bmp2.bmp");
            pnm1 = new vtkPNMWriter();
            pnm1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            pnm1.SetFileName((string)"" + (dir.ToString()) + "/pnm1.pnm");
            pnm2 = new vtkPNMWriter();
            pnm2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
            pnm2.SetFileName((string)"" + (dir.ToString()) + "/pnm2.pnm");
            psw1 = new vtkPostScriptWriter();
            psw1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            psw1.SetFileName((string)"" + (dir.ToString()) + "/psw1.ps");
            psw2 = new vtkPostScriptWriter();
            psw2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
            psw2.SetFileName((string)"" + (dir.ToString()) + "/psw2.ps");
            pngw1 = new vtkPNGWriter();
            pngw1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            pngw1.SetFileName((string)"" + (dir.ToString()) + "/pngw1.png");
            pngw2 = new vtkPNGWriter();
            pngw2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
            pngw2.SetFileName((string)"" + (dir.ToString()) + "/pngw2.png");
            jpgw1 = new vtkJPEGWriter();
            jpgw1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
            jpgw1.SetFileName((string)"" + (dir.ToString()) + "/jpgw1.jpg");
            jpgw2 = new vtkJPEGWriter();
            jpgw2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
            jpgw2.SetFileName((string)"" + (dir.ToString()) + "/jpgw2.jpg");
            tiff1.Write();
            tiff2.Write();
            bmp1.Write();
            bmp2.Write();
            pnm1.Write();
            pnm2.Write();
            psw1.Write();
            psw2.Write();
            pngw1.Write();
            pngw2.Write();
            jpgw1.Write();
            jpgw2.Write();
            File.Delete("" + (dir.ToString()) + "/tiff1.tif");
            File.Delete("" + (dir.ToString()) + "/tiff2.tif");
            File.Delete("" + (dir.ToString()) + "/bmp1.bmp");
            File.Delete("" + (dir.ToString()) + "/bmp2.bmp");
            File.Delete("" + (dir.ToString()) + "/pnm1.pnm");
            File.Delete("" + (dir.ToString()) + "/pnm2.pnm");
            File.Delete("" + (dir.ToString()) + "/psw1.ps");
            File.Delete("" + (dir.ToString()) + "/psw2.ps");
            File.Delete("" + (dir.ToString()) + "/pngw1.png");
            File.Delete("" + (dir.ToString()) + "/pngw2.png");
            File.Delete("" + (dir.ToString()) + "/jpgw1.jpg");
            File.Delete("" + (dir.ToString()) + "/jpgw2.jpg");
        }


        viewer = new vtkImageViewer();
        viewer.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
        viewer.SetColorWindow((double)255);
        viewer.SetColorLevel((double)127.5);
        viewer.Render();

//deleteAllVTKObjects();
    }
    /// <summary>
    /// The main entry method called by the CSharp driver
    /// </summary>
    /// <param name="argv"></param>
    public static void AVTestImageWriters(String [] argv)
    {
        //Prefix Content is: ""

          // Image pipeline[]
          image1 = new vtkTIFFReader();
          image1.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/beach.tif");
          // "beach.tif" image contains ORIENTATION tag which is []
          // ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF []
          // reader parses this tag and sets the internal TIFF image []
          // orientation accordingly.  To overwrite this orientation with a vtk[]
          // convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke[]
          // SetOrientationType method with parameter value of 4.[]
          image1.SetOrientationType((uint)4);
          image1.Update();
          sp = new vtkStructuredPoints();
          sp.SetDimensions(image1.GetOutput().GetDimensions()[0],image1.GetOutput().GetDimensions()[1],image1.GetOutput().GetDimensions()[2]);
          sp.SetExtent(
          image1.GetOutput().GetExtent()[0],
          image1.GetOutput().GetExtent()[1],
          image1.GetOutput().GetExtent()[2],
          image1.GetOutput().GetExtent()[3],
          image1.GetOutput().GetExtent()[4],
          image1.GetOutput().GetExtent()[5]);
          //sp.SetScalarType((int)image1.GetOutput().GetScalarType());
          //sp.SetNumberOfScalarComponents((int)image1.GetOutput().GetNumberOfScalarComponents());
          vtkDataObject.SetPointDataActiveScalarInfo(sp.GetInformation(), (int)image1.GetOutput().GetScalarType(), (int)image1.GetOutput().GetNumberOfScalarComponents());

          sp.GetPointData().SetScalars((vtkDataArray)image1.GetOutput().GetPointData().GetScalars());
          luminance = new vtkImageLuminance();
          luminance.SetInputData((vtkDataObject)sp);
          //[]
          // write to the temp directory if possible, otherwise use .[]
          //[]
          dir = ".";
          dir = TclToCsScriptTestDriver.GetTempDirectory();

          // make sure it is writeable first[]
          try
          {
         channel = new StreamWriter("" + (dir.ToString()) + "/test.tmp");
          tryCatchError = "NOERROR";
          }
          catch(Exception)
          {tryCatchError = "ERROR";}

        if(tryCatchError.Equals("NOERROR"))
          {
          channel.Close();
          File.Delete("" + (dir.ToString()) + "/test.tmp");
          tiff1 = new vtkTIFFWriter();
          tiff1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          tiff1.SetFileName((string)"" + (dir.ToString()) + "/tiff1.tif");
          tiff2 = new vtkTIFFWriter();
          tiff2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          tiff2.SetFileName((string)"" + (dir.ToString()) + "/tiff2.tif");
          bmp1 = new vtkBMPWriter();
          bmp1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          bmp1.SetFileName((string)"" + (dir.ToString()) + "/bmp1.bmp");
          bmp2 = new vtkBMPWriter();
          bmp2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          bmp2.SetFileName((string)"" + (dir.ToString()) + "/bmp2.bmp");
          pnm1 = new vtkPNMWriter();
          pnm1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          pnm1.SetFileName((string)"" + (dir.ToString()) + "/pnm1.pnm");
          pnm2 = new vtkPNMWriter();
          pnm2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          pnm2.SetFileName((string)"" + (dir.ToString()) + "/pnm2.pnm");
          psw1 = new vtkPostScriptWriter();
          psw1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          psw1.SetFileName((string)"" + (dir.ToString()) + "/psw1.ps");
          psw2 = new vtkPostScriptWriter();
          psw2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          psw2.SetFileName((string)"" + (dir.ToString()) + "/psw2.ps");
          pngw1 = new vtkPNGWriter();
          pngw1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          pngw1.SetFileName((string)"" + (dir.ToString()) + "/pngw1.png");
          pngw2 = new vtkPNGWriter();
          pngw2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          pngw2.SetFileName((string)"" + (dir.ToString()) + "/pngw2.png");
          jpgw1 = new vtkJPEGWriter();
          jpgw1.SetInputConnection((vtkAlgorithmOutput)image1.GetOutputPort());
          jpgw1.SetFileName((string)"" + (dir.ToString()) + "/jpgw1.jpg");
          jpgw2 = new vtkJPEGWriter();
          jpgw2.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          jpgw2.SetFileName((string)"" + (dir.ToString()) + "/jpgw2.jpg");
          tiff1.Write();
          tiff2.Write();
          bmp1.Write();
          bmp2.Write();
          pnm1.Write();
          pnm2.Write();
          psw1.Write();
          psw2.Write();
          pngw1.Write();
          pngw2.Write();
          jpgw1.Write();
          jpgw2.Write();
          File.Delete("" + (dir.ToString()) + "/tiff1.tif");
          File.Delete("" + (dir.ToString()) + "/tiff2.tif");
          File.Delete("" + (dir.ToString()) + "/bmp1.bmp");
          File.Delete("" + (dir.ToString()) + "/bmp2.bmp");
          File.Delete("" + (dir.ToString()) + "/pnm1.pnm");
          File.Delete("" + (dir.ToString()) + "/pnm2.pnm");
          File.Delete("" + (dir.ToString()) + "/psw1.ps");
          File.Delete("" + (dir.ToString()) + "/psw2.ps");
          File.Delete("" + (dir.ToString()) + "/pngw1.png");
          File.Delete("" + (dir.ToString()) + "/pngw2.png");
          File.Delete("" + (dir.ToString()) + "/jpgw1.jpg");
          File.Delete("" + (dir.ToString()) + "/jpgw2.jpg");
        }

          viewer = new vtkImageViewer();
          viewer.SetInputConnection((vtkAlgorithmOutput)luminance.GetOutputPort());
          viewer.SetColorWindow((double)255);
          viewer.SetColorLevel((double)127.5);
          viewer.Render();

        //deleteAllVTKObjects();
    }