[vtkusers] Copy image data into vtkImageData from a textfile

Lizeth Castellanos castellanoslizan at gmail.com
Wed Jul 18 14:42:20 EDT 2018


Hi!

I'd like to copy image data from a textfile (csv) into vtkImageData.
The textfile have voxel values for x,y,z  and image intensity. I already
have read the textfile into VTK with the vtkDelimitedTextReader class:

Table loaded from CSV file:
+-----------+-----------+-----------+------------+
| Field 0   | Field 1   | Field 2   | Field 3    |
+-----------+-----------+-----------+------------+
| 510       | 291       | 0             | 32           |
| 511       | 291       | 0             | 128         |
| 510       | 292       | 0             | 104         |
| 511       | 292       | 0             | 104         |
| 510       | 293       | 0             | 40           |
| 511       | 293       | 0             | 240         |
| 510       | 294       | 0             | 104         |
| 511       | 294       | 0             | 96           |
| 506       | 295       | 0             | 64           |
| 507       | 295       | 0             | 16           |
 .....
 .....
The file is an exported segmented dataset.

I am following the tips from this similar question
http://vtk.1045678.n5.nabble.com/importing-image-data-into-VTK-from-textfile-mimics-td1243332.html
I have created an appropriate  vtkimagedata (volume):

imageData = vtk.vtkImageData()
imageData.SetDimensions(512, 512, 192)
imageData.SetOrigin(0.0, 0.0, 0.0)
imageData.SetSpacing(1, 1, 1)
imageData.SetNumberOfScalarComponents(1)
imageData.Update()

However I don't know how to copy the data loaded from
vtkDelimitedTextReader into vtkImageData. How do I copy the x,y,z voxel
values into vtkImageData? How do I copy the intensity valuesVtkImageData?

Any help provided for this would be greatly appreciated!

Lizeth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180718/fae4721a/attachment.html>


More information about the vtkusers mailing list