Hi all,
I have some problems managing a large set of raw pics, exactly 4759
512x512 images.
Since I couldn't load the whole set with vtkImageReader2 (an ugly crash
would happen) I decided to read the set 100 pics at a time, and then
recombine the datase by a vtkImageCast filter. The question is, how can
I set vtkImageCast filter in order to rebuild the volume represented by
the dataset I am referring into? Is it a better way to do it (I'm
working in Java, this is why I chose vtkImageCast to obtain an unsigned
short image)?
What I had in mind was something like this:
vtkImageReader2 reader = new vtkImageReader2();
reader.SetDataByteOrderToLittleEndian();
reader.SetFilePrefix(PATH_TO_LARGE_DATASET + filePrefix);
reader.SetFilePattern("%s%d.raw");
reader.SetDataSpacing(0.45703125, 0.45703125, 0.6); //Or some values depending on the set
vtkImageCast img = new vtkImageCast();
vtkImageData image = new vtkImageData();
img.SetInputConnection(reader.GetOutputPort());
img.SetOutputScalarTypeToUnsignedShort();
img.SetOutput(image);
int numberOf100Subsets = (int) NumberOfImages / 100;
int numberOfLeftSlices = (int) NumberOfImages % 100;
double origin[] = new double[3];
if (numberOf100Subsets > 1) {
for (int i = 1; i < numberOf100Subsets + 1; i++) {
reader.SetDataExtent(0, 511, 0, 511, 100 * (i - 1) + 1, 100 * i);
reader.Update();
if (i == 1) {
origin = reader.GetDataOrigin();
}
System.out.println(100 * i + " images loaded");
img.GetOutput().SetOrigin(reader.GetOutput().GetOrigin()); // Maybe this is wrong?
}
reader.SetDataExtent(0, 511, 0, 511, (100 * numberOf100Subsets + 1), 100 * NumberOf100Subsets + numberOfLeftSlices);
reader.Update();
System.out.println(100 * numberOf100Subsets + numberOfLeftSlices + " images loaded");
} else {
reader.SetDataExtent(0, 511, 0, 511, 1, NumberOfImages);
reader.Update();
}
<br><hr align="left" width="300">
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Loading-a-large-dataset-with-vtkImageReader2-and-vtkImageCast-tp3352813p3352813.html">Loading a large dataset (with vtkImageReader2 and vtkImageCast)</a><br>
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br>