[vtkusers] Re: image resizing - spacing/extent problems?
Tim Hutton
tim.hutton at gmail.com
Fri Sep 21 05:10:35 EDT 2007
I've got a solution, but I'm even more confused. Perhaps someone wiser
than me can explain.
Works:
downsampler->Update();
downsampler->GetOutput()->SetSpacing(1.0,1.0,1.0);
(then the spacing and the extent are as desired)
Doesn't work: (any combination of)
downsampler->SetOutputSpacing(1.0,1.0,1.0);
or
downsampler->SetAxisOutputSpacing(0,1.0);
downsampler->SetAxisOutputSpacing(1,1.0);
or
downsampler->SetOutputExtent();
In any case I don't want to set the extent manually, it should really
come from the filter.
Thanks for any hints,
Tim
On 20/09/2007, Tim Hutton <tim.hutton at gmail.com> wrote:
> Hello,
>
> I'm trying to shrink an image (to make image pyramids). The following
> code appears to work:
>
> vtkImageResample *downsampler = vtkImageResample::New();
> downsampler->SetInput(smoother->GetOutput());
> downsampler->SetInterpolationModeToLinear();
> downsampler->SetDimensionality(2);
> double shrink_factor = pow(0.5,(double)iCurrentLevel);
> downsampler->SetAxisMagnificationFactor(0,shrink_factor);
> downsampler->SetAxisMagnificationFactor(1,shrink_factor);
> downsampler->Update();
>
> When I save out the image it appears at the size I want. However, the
> rest of my algorithm doesn't work unless I then read-in the image I've
> just saved out, and use that instead. What would cause this odd
> behaviour? Could it be something to do with the extent, or the
> spacing, or the origin?
>
> Many thanks for any guidance.
>
> --
> Tim Hutton - http://www.sq3.org.uk
>
> Take the Organic Builder challenge -
> http://www.sq3.org.uk/Evolution/Squirm3/OrganicBuilder/
>
--
Tim Hutton - http://www.sq3.org.uk
Take the Organic Builder challenge -
http://www.sq3.org.uk/Evolution/Squirm3/OrganicBuilder/
More information about the vtkusers
mailing list