[vtkusers] vtkImageData resampling
Tony
bowler0_uk at yahoo.com
Wed Jan 15 04:38:35 EST 2014
Dear list,
I am having problems with vtkImageResample I frequently want to resample images and I currently use a procedure along the lines of
vtkSmartPointer<vtkImageResample>resampler=
vtkSmartPointer<vtkImageResample>::New();
resampler->SetInput(imgData);
resampler->SetDimensionality(3);
resampler->SetAxisOutputSpacing(0,spx);
resampler->SetAxisOutputSpacing(1,spy);
resampler->SetAxisOutputSpacing(2,spz);
resampler->Update();
vtkSmartPointer<vtkImageChangeInformation>v16=
vtkSmartPointer<vtkImageChangeInformation>::New();
v16->SetInputConnection(resampler->GetOutputPort());
v16->SetOutputSpacing(spx,spy,spz);
v16->Update();
which I imagine I got from an example some time ago. I have found this method to be rather unstable in
that certain values of grid spacing will cause a runtime error. The values of spx, spy and spz that cause
a crash are rather unpredictable in that I can't see a patttern between the characteristics of the input
data and values that result in a crash. It is often quite chaotic for example SetSpacing(2, 2, 2) and
SetSpacing(2.2, 2.2, 2.2) might cause a crash whilst SetSpacing(2.1, 2.1, 2.1) will be fine.
Is there any obvious gremlin in the above code? If not is there a more general way about going about this?
Perhaps I've been rather lazy in that I haven't taken the time to explore how vtkImageResample works in
detail, I don't know if the new spacing has to be an exact multiple of the old one or vice versa.
Thanks.
More information about the vtkusers
mailing list