[vtkusers] Re: image resizing - spacing/extent problems?

David Gobbi david.gobbi at gmail.com
Fri Sep 21 09:46:38 EDT 2007


Hi Tim,

With VTK 5, whenever I want to force an update, I always call the update
on the data rather than on the filter:

filter->GetOutput()->UpdateInformation();
filter->GetOutput()->Update();

The reason is that, in VTK 5, the "information" is stored in two places: it is
stored in the information objects associated with the output ports, and it
is also (separately) stored in the data objects.

Especially when trying to port code from VTK 4 to VTK 5, I have occasionally
found that the information objects are updated but not the data.  Calling
the update specifically on the data object will force the data object to
update its copy of the information.

 David


On 9/21/07, Tim Hutton <tim.hutton at gmail.com> wrote:
> 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/
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list