[Insight-users] problems with resample filter

Bryn Alexander Lloyd blloyd at bwh.harvard.edu
Wed May 25 19:52:09 EDT 2005


Hi Luis,

Thank you for your quick reply.
filter->UpdateLargestPossibleRegion()  did the trick.

I was playing around with the image, accessing data, because when I tried
to create a copy of the image with itkImageDuplicator I got the first
segmentation fault.

The output grid in my code is defined by another image, the original
image, which I downsampled by a factor.
The steps I was taking are:
- downsample image 256x256 to 50x50 (as in the example
ResampleImageFilter2.cxx)
- do some operations (intensity correction based
    on Kullback-Leibler divergence to a model image)
- resample the correction field from 50x50 to 256x256
- use correction field to correct original image.

Thanks again,

Bryn


<quote who="Luis Ibanez">
>
> Hi Bryn
>
> You *should not* touch the regions of an image that
> have been obtained from the GetOutput() of a filter.
>
> The filter is still in control of the regions used
> by the pipeline.
>
> If what you want is to make sure that the Update()
> generate the full image, then you should just call
>
>       filter->UpdateLargestPossibleRegion()
>
> instead of
>
>       filter->Update()
>
>
> Note also that the images that are generated as output
> from a filter, cannot (should not) be modified. In other
> words, they are read-only images.
>
>
>
>  From your code snippet, we don't see where did you defined
> the output grid for the resampled image. This is quite
> important and its lack may well be the cause of the segmentation
> faults.
>
>
> For details on how to use the itk::ResampleImageFilter
> correctly you may want to look at the ITK Software Guide
>
>
>       http://www.itk.org/ItkSoftwareGuide.pdf
>
>
> Section 6.9, pdf-pages 245 to 272.
>
>
>
>
>
>
>       Regards,
>
>
>
>
>         Luis
>
>
>
>
>
> -------------------------------
> Bryn Alexander Lloyd wrote:
>
>> Hi,
>>
>> I am trying to use the itk::ResampleImageFilter to upsample an image.
>> As an example I would like create an image with 256x256 pixels from an
>> image with 50x50 pixels.
>>
>> For some reason if I try to access the output image data with an
>> iterator,
>> I get a segmentation fault.
>> The same happens if I try to write an image after setting the
>> BufferedRegion to the LargestPossibleRegion. (It seems to work if don't
>> set the region to the largest possible). I am using the
>> LinearImageInterpolatorFunction.
>>
>>
>> Why is this? Can anybody help me with this?
>>
>> Thanks,
>>
>>
>>
>>   resamplefilter->SetOutputSpacing(Ioriginal->GetSpacing );
>>   resamplefilter->SetOutputOrigin( Ioriginal->GetOrigin() );
>>
>>   resamplefilter->SetInput( Isubsampled );
>>   resamplefilter->Update();
>>   Inew = resamplefilter->GetOutput();
>>
>>   //Inew->SetBufferedRegion(Inew->GetLargestPossibleRegion());
>>   //Inew->SetRequestedRegion(Inew->GetLargestPossibleRegion());
>>
>>   writer->SetInput( Inew );
>>   writer->SetFileName("Inew.mhd");
>>   writer->Update();
>>
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
>
>
>




More information about the Insight-users mailing list