[vtkusers] how to change image order
David Gobbi
david.gobbi at gmail.com
Mon Dec 21 14:47:31 EST 2009
On Mon, Dec 21, 2009 at 12:05 PM, Lic. José M. Rodriguez Bacallao
<jmrbcu at gmail.com> wrote:
>> There is no filter to reorganize the vtkImageData
>> slices with strides and such. I had to read in the data
>> slice-by-slice (i.e. a different reader for each slice) and use
>> vtkImageAppend to put it together in the right order.
>
> how do U do that? could U send me an example code?
The English second-person pronoun is "you." I've never met this "U" person.
Actually, I just remembered that doing ImageAppend isn't necessary in
VTK anymore. It's possible for vtkImageReader2 to sort the slices in
whatever order you want, so as long as vtkGDCMReader inherits from
vtkImageReader2, then it should be able to do this too. Here is what
to do:
In VTK, there is a class called vtkStringArray, that is a list of
strings. You can use it to store all of the slice filenames of the
DICOM series that you want to read, just make sure that all the
filenames in the vtkStringArray are in the right order.
vtkStringArray *sliceList = vtkStringArray::New();
sliceList->InsertNextValue("slice1.dcm");;
sliceList->InsertNextValue("slice2.dcm");
etc.
Then you do the following:
reader->SetFileNames(sliceList);
Mathieu might know whether this will work with the GDCM reader. There
are also classes to help create a vtkStringArray from a directory of
files: vtkGlobFileNames and vtkSortFileNames.
David
More information about the vtkusers
mailing list