[Insight-users] rescaling problems
Luis Ibanez
luis . ibanez at kitware . com
Thu, 03 Jul 2003 01:43:37 -0400
Hi Sven,
Your code looks ok,
and the application of the factor scaling for
reducing the size is perfectly valid.
I guess that you may be experiencing a pipeline update problem.
Do you have more filters after the ResampleImageFilter ?
Are you calling Update() in any of those downstream filters ?
I would suggest you to try calling "UpdateLargestPossibleRegion()"
instead of just "Update()".
For performance reasons, the pipeline only performs region negociations
the first time it is executed. Calling UpdateLargestPossibleRegion()
forces the pipeline to repeat the region negociation each time.
This is quite important when you are changing the image size as
a consequence of some parameter settings.
Please let us know if you continue experiencing any problems,
Thanks
Luis
-----------------------
Sven Prevrhal wrote:
> I?d like to sample a CT volume onto a coarser grid and am having
> trouble. The resampleFilter Update throws an exception saying at least a
> part of the requested region is outside the maximum size, but only if I
> request a smaller size! Here?s my code with the problem description
> commented:
>
>
>
> m_ResampleTransform->SetIdentity();
>
>
>
> ImageSizeType scaledSize;
>
>
>
> ImageSizeType size = m_ImageReader->GetOutput()->
>
> GetBufferedRegion().GetSize();
>
>
>
> //From the GUI:
>
> this->m_SpacingFactor[0] = xValue;
>
> this->m_SpacingFactor[1] = yValue;
>
> this->m_SpacingFactor[2] = zValue;
>
>
>
> double * scaledSpacing = new double[ImageDimension];
>
>
>
> const double * spacing = m_ImageReader->GetOutput()->GetSpacing();
>
>
>
> for( int i = 0; i < ImageDimension; i++ ) {
>
>
>
> scaledSpacing[i] = spacing[i] * m_SpacingFactor[i];
>
>
>
> // Here?s the problem: If I leave
>
> // scaledSize[i] = size[i];
>
> // it doesn?t crash,
>
> // but I get a lot of zero voxels around. Setting
>
> scaledSize[i] = size[i] / m_SpacingFactor[i];
>
> // should take the excess voxel out, but it crashes!
>
> }
>
>
>
> m_ResampleFilter->SetSize( scaledSize );
>
> m_ResampleFilter->SetOutputSpacing( (const double *) scaledSpacing );
>
> m_ResampleFilter->Modified();
>
>
>
> // Update somewhere else, but that?s when it crashes
>
>
>
> Example: I have 512x512xn input, want to resample onto 256x256xn output,
> I choose the m_SpacingFactors 2.0,2.0,1.0. Setting size to 256x256xn ->crash!
>
>
>
> This shouldn?t be hard, but for some reason I am stuck. Any ideas
> totally appreciated!!
>
>
>
> sven
>
> --
>
>
>