[vtkusers] convert unsigned VTkimagedata to signed one

Ali Habib ali.mahmoud.habib at gmail.com
Sun Mar 7 15:33:49 EST 2010


Dear David,

the proplem in vtkimageactor wich is complain, after applying your code the
same error appear
any suggesion please


vtk.vtkDICOMImageReader VDR = new vtk.vtkDICOMImageReader();
            VDR.SetDirectoryName(@"G:\Master
Degree\DataSet\case2\DICOM\PA1\ST1\SE2");
            VDR.SetDataOrigin(0, 0, 0);
            VDR.Update();

            vtkImageShiftScale ss = new vtkImageShiftScale();
            ss.SetOutputScalarTypeToUnsignedChar();
                 ss.SetInputConnection(VDR.GetOutputPort());
                ss.Update();

            // decrease the dataset data for large data preprocessing

            vtkImageShrink3D VIS = new vtkImageShrink3D();
            VIS.SetShrinkFactors(2, 2, 2);
            VIS.SetInputConnection(ss.GetOutputPort());
            VIS.Update();

            vtkImageThreshold VIT = new vtkImageThreshold();
            VIT.ThresholdBetween(200, 2000);
            VIT.SetInputConnection(VIS.GetOutputPort());
            VIT.Update();

            ///// Start the creation of volume rendering

            //1. Gget the range of data
            vtk.vtkImageChangeInformation VIC = new
vtk.vtkImageChangeInformation();
            VIC.SetInput(VDR.GetOutput());
            VIC.CenterImageOn();
            VIC.Update();

            vtk.vtkImageData VoxelData = new vtk.vtkImageData();
            VoxelData = VIC.GetOutput();
            VoxelData.AllocateScalars();

            vtkImageActor imageActor = new vtkImageActor();
            imageActor.SetInput(VoxelData);


 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Create the RenderWindow, Renderer and both Actors
            //
            vtkRenderer ren1 = new vtkRenderer();
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer(ren1);
            vtkRenderWindowInteractor iren = new
vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);

            // Add the actors to the renderer, set the background and size
            //
            ren1.AddActor(imageActor);
            ren1.SetBackground(.1, .2, .4);



            ren1.ResetCamera();
            ren1.ResetCameraClippingRange();

            renWin.Render();



On Sun, Mar 7, 2010 at 10:25 PM, David Feng <d.feng1 at gmail.com> wrote:

> I'm assuming it's the vtkImageShrink3D filter that's complaining.  I'm
> surprised it only handles unsigned chars.  vtkImageShiftScale will
> convert from one type to another:
>
> vtkImageShiftScale ss = vtk.vtkImageShiftScale()
> ss.SetOutputScalarTypeToUnsignedChar()
> ss.SetInputConnection(VDR.GetOutputPort())
> ss.Update()
>
> vtkImageResample might be able to do the resampling you need without
> the unsigned char restriction.  Not sure though.
>
> David
>
> On Sun, Mar 7, 2010 at 2:21 PM, Ali Habib <ali.mahmoud.habib at gmail.com>
> wrote:
> > Dear All,
> > I read DICOm data to VTK image data and display it but it give error that
> > "this filter requires unsigned char scalar " I want to convert the data
> to
> > unsigned char
> > the code use:
> >             vtk.vtkDICOMImageReader VDR = new vtk.vtkDICOMImageReader();
> >             VDR.SetDirectoryName(@"G:\Master
> > Degree\DataSet\case2\DICOM\PA1\ST1\SE2");
> >             VDR.SetDataOrigin(0, 0, 0);
> >             VDR.Update();
> >             // decrease the dataset data for large data preprocessing
> >             vtkImageShrink3D VIS = new vtkImageShrink3D();
> >             VIS.SetShrinkFactors(2, 2, 2);
> >             VIS.SetInputConnection(VDR.GetOutputPort());
> >             VIS.Update();
> >             vtkImageThreshold VIT = new vtkImageThreshold();
> >             VIT.ThresholdBetween(200, 2000);
> >             VIT.SetInputConnection(VIS.GetOutputPort());
> >             VIT.Update();
> >             ///// Start the creation of volume rendering
> >             //1. Gget the range of data
> >             vtk.vtkImageChangeInformation VIC = new
> > vtk.vtkImageChangeInformation();
> >             VIC.SetInput(VDR.GetOutput());
> >             VIC.CenterImageOn();
> >             VIC.Update();
> >             vtk.vtkImageData VoxelData = new vtk.vtkImageData();
> >             VoxelData = VIC.GetOutput();
> >             VoxelData.AllocateScalars();
> >             vtkImageActor imageActor = new vtkImageActor();
> >             imageActor.SetInput(VoxelData);
> >
> >
>  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> >             // Create the RenderWindow, Renderer and both Actors
> >             //
> >             vtkRenderer ren1 = new vtkRenderer();
> >             vtkRenderWindow renWin = new vtkRenderWindow();
> >             renWin.AddRenderer(ren1);
> >             vtkRenderWindowInteractor iren = new
> > vtkRenderWindowInteractor();
> >             iren.SetRenderWindow(renWin);
> >             // Add the actors to the renderer, set the background and
> size
> >             //
> >             ren1.AddActor(imageActor);
> >             ren1.SetBackground(.1, .2, .4);
> >
> >
> >             ren1.ResetCamera();
> >             ren1.ResetCameraClippingRange();
> >             renWin.Render();
> > Best regards
> >
> >
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
>
>
>
> --
> http://www.cs.unc.edu/~dfeng
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100307/c4e08be5/attachment.htm>


More information about the vtkusers mailing list