[vtkusers] Writing Out Image Data After Modifying Point Arrays

Grant McAuley gmcauley at llu.edu
Mon Sep 19 22:05:02 EDT 2016


On Mon, Sep 19, 2016 at 5:02 PM, Grant Mc Auley <gamcauley at gmail.com> wrote:

>
> I have a vti file that contains several PointData arrays containing
> 3-tuples.  Many of the 3-tuples contain all zeros and, after reading in the
> file I remove them, essentially like:
>
> xmlreader = vtk.vtkXMLImageDataReader()
> xmlreader.SetFileName(self.__filename)
> xmlreader.Update()
>                 image_data = xmlreader.GetOutput()
> image_point_data = image_data.GetPointData()
>                 ...
>                 if math.sqrt(x_ ** 2 + y_ ** 2 + z_ ** 2) == 0.0:
>
>                     image_point_data.RemoveArray(index)
>
> Now, I want to write out a new file with the cleaned-up arrays using:
>
> xml_image_writer = vtk.vtkXMLImageDataWriter()
> xml_image_writer.SetFileName(filename)
> xml_image_writer.SetDataModeToBinary()
>
> # self.__image_data.SetDimensions(51905, 1, 1)
> xml_image_writer.SetInputData(self.__image_data)
> xml_image_writer.Write()
>
>
> However, there are at least two issue I am not sure how to handle:
> [program output]
> Number of points: 266688
> ERROR: In /build/buildd/vtk6-6.1.0+dfsg/Common/DataModel/vtkDataSet.cxx,
> line 414
> vtkImageData (0x1632f50): Point array array_1 with 3 components, only has
> 51905 tuples but there are 266688 points
> [/program output]
>
> 1) The number of 3-tuples no longer matches the number of points in the
> image data structure, and ...
>
> 2) Even if I try to remedy this by putting the correct number in
> getDimensions() above, it will still not be correct for the other arrays
> since in the number of 'zero tuples' removed from each is in general
> different
>
> Finally, I will need to combine the contents of point arrays of the same
> name in multiple files by appending the data from each file into one.
> Something like:
>
> <VTKFile type="ImageData">>
>    <ImageData WholeExtent="0 ? 0 0 0 0" Origin="0 0 0" Spacing="1 1 1">
>       <Piece Extent="0 ? 0 0 0 0">
>          <PointData>
>             <DataArray type="Float64" Name="array1" NumberOfComponents="3"
>          RangeMin="0.1" RangeMax="100">
> 1 2 3 4 5 6 7 8 9 10 11 12
>             </DataArray>
>             <DataArray type="Float64" Name="array2" NumberOfComponents="3"
>          RangeMin="0.1" RangeMax="100">
> 50 100 150 200
>             </DataArray>
>                  ...
> AND
>
> <VTKFile type="ImageData">>
>    <ImageData WholeExtent="0 ? 0 0 0 0" Origin="0 0 0" Spacing="1 1 1">
>       <Piece Extent="0 ? 0 0 0 0">
>          <PointData>
>             <DataArray type="Float64" Name="array1" NumberOfComponents="3"
>          RangeMin="0.1" RangeMax="100">
> 13 14 15 16 17 18 19 20 21
>             </DataArray>
>             <DataArray type="Float64" Name="array2" NumberOfComponents="3"
>          RangeMin="0.1" RangeMax="100">
> 250 300 350
>             </DataArray>
>                  ...
>                  ...
>
> COMBINED INTO:
>
> <VTKFile type="ImageData">>
>    <ImageData WholeExtent="0 ? 0 0 0 0" Origin="0 0 0" Spacing="1 1 1">
>       <Piece Extent="0 ? 0 0 0 0">
>          <PointData>
>             <DataArray type="Float64" Name="array1" NumberOfComponents="3"
>          RangeMin="0.1" RangeMax="100">
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
>             </DataArray>
>             <DataArray type="Float64" Name="array2" NumberOfComponents="3"
>          RangeMin="0.1" RangeMax="100">
> 50 100 150 200 250 300 350
>             </DataArray>
>                  ...
>
> Any guidance/suggestions/info/corrections would be much appreciated.
>
>


-- 
Grant McAuley, PhD
Assistant Professor
Radiation Medicine
Loma Linda University
(909) 558-8082 Ext 88082
gmcauley at llu.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160919/51d976b4/attachment.html>


More information about the vtkusers mailing list