[Insight-users] converting file types
Sara Rolfe
smrolfe at u.washington.edu
Mon May 7 19:22:40 EDT 2012
Hi David,
I just checked and it is image data, so I should be able to use this
method.
I have one quick follow on question. I need the .mhd file to pass to
another program I wrote, which uses the proper type of reader for a 3D
vector field. When I use the misnamed vtk file, the program gets
stuck. Now that I'm looking at the details and see that the .vtk
format should still contain a 3D vector field, I don't understand why
the difference in the filename extension is causing an issue. Is
there anything obvious that I've missed?
Thanks,
Sara
On May 7, 2012, at 4:04 PM, David Doria wrote:
> 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