[Insight-users] converting file types
David Doria
daviddoria at gmail.com
Mon May 7 19:04:19 EDT 2012
On Mon, May 7, 2012 at 6:22 PM, Sara Rolfe <smrolfe at u.washington.edu> wrote:
> Hello,
>
> I have some vector fields which were written with the extension "vtk"
> instead of "mhd" as needed. Is there a simple way to convert between these
> two file types?
>
> Thanks,
> Sara
.vtk is a legacy format that I believe can contain many types of data
(vtkImageData, vtkPolyData, etc). If you open the .vtk in Paraview you
should be able to tell if it is image data or polydata. Then you can
use the appropriate VTK reader to read the data. If it is vtkImageData
(hopefully), I would then use an ITK iterator to iterate over the
target ITK image, and use the .GetIndex() as an index into the
vtkImageData to copy the data from the VTK image into the target ITK
image.
You'll need this idea:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData
Let us know if you have any trouble - there are a couple of
confusingly named functions you'll need if the data is a vtkPolyData.
David
More information about the Insight-users
mailing list