[vtkusers] How to convert vtkImageCast back to vtkImageData
David Gobbi
david.gobbi at gmail.com
Sat Jun 13 09:06:35 EDT 2015
Hi Quental,
The solution is as follows:
cast.Update()
implicit_volume.SetVolume(cast.GetOutput())
The VTK pipeline recognizes two very distinct kinds of objects:
The vtkImageCast object is a vtk "algorithm" object (derived from
vtkAlgorithm).
The vtkImageData object is a vtk "data" object (derived from vtkDataObject).
An algorithm can never be data. An algorithm _operates_ on data.
So the algorithm's input is data, and its output is data.
- David
On Sat, Jun 13, 2015 at 6:36 AM, Quentan Qi <quentan at gmail.com> wrote:
> Hi there,
>
> After casting an image using vtkImageCast, it becomes a vtkImageCast
> object, but I want to use vtkImplicitVolume which requires vtkImageData
> type. How to convert vtkImageCast back to vtkImageData?
>
> ```Python
>
> reader = read_DICOM(path_dicom) # result is a vtkImageData
>
> cast = vtk.vtkImageCast()
> cast.SetInputData(reader) # vtkImageData —> vtkImageCast
> cast.SetOutputScalarTypeToShort() # I need this type
>
> implicit_volume = vtk.vtkImplicitVolume()
> implicit_volume.SetVolume(reader) # It works but I need “cast” instead
> # implicit_volume.SetVolume(cast) # It’s wrong because vtkImageData is
> required, but a vtkImageCast was given
> # other things
>
> ```
>
> Thanks a lot!
>
> Cheers,
> Quentan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150613/a3ffb821/attachment.html>
More information about the vtkusers
mailing list