[Insight-users] Passing itk images to functions

Luis Ibanez luis.ibanez at kitware.com
Sun Oct 17 10:37:11 EDT 2010


Hi habibbaluwala,

I don't think that the API of the image was
designed to allow for in-place resizing of
the image.

The Update() call certainly will not do the
trick.

You may want to try calling  Allocate(),
just after you change the image regions
inside that function...

but again,

I will be surprised if that works...

---

Let's go back to basics:

1) Were you expecting (or hoping) that
    the pixel content of the image will
    remain untouched as you resize it ?

2) If so, what you need to use is the
    ResampleImageFilter...

3) Or the RegionOfInterestImageFilter
    (if the new region is smaller than
    the original one).


You may find useful to look at the
ITK Software Guide:

  http://www.itk.org/ItkSoftwareGuide.pdf

In particular, to

Section 6.9.4 "Resample Image Filter"
in pdf-page 254, up to page 284.




  Regards,


       Luis


----------------------------------------------------------------------
On Tue, Sep 28, 2010 at 1:00 PM, habibbaluwala2010
<habibbaluwala at gmail.com>wrote:

>
> Hello Everyone ,
>                       I have been suffering with a minor problem where any
> changes that I make in the image in a supplementary function is not
> reflected in the main function. I.e. if I change the size of the image in
> the function that change is not reflected in the Main function . The
> example
> below will provide a brief review:
>
>
>
> template<typename RType>
> void image_resize_filter (RType *test_image)
> {
>   RType:: IndexType start; start[0]=0;start[1]=0;start[2]=0;
>   RType::RType imageSize;
>   imageSize[0]=200;
>   imageSize[1]=200;
>   imageSize[2]=200;
>   RType::RegionType region;
>   region.SetSize(imageSize); region.SetIndex(start);
>   test_image->SetRegions(region);
>   test_image->Update();
>
> }
>
>
> void main ()
> {
>   typedef float PixelType;
>   const unsigned int Dimension = 3;
>   typedef itk::Image< PixelType, Dimension > ImageType;
>   ImageType:: IndexType start; start[0]=0;start[1]=0;start[2]=0;
>
>   ImageType::SizeType imageSize;
>   imageSize[0]=100;
>   imageSize[1]=100;
>   imageSize[2]=100;
>   ImageType::Pointer test1=ImageType::New();
>   ImageType::RegionType region;
>   region.SetSize(imageSize); region.SetIndex(start);
>   test1->SetRegions(region); test1->Allocate();
>   test1->FillBuffer(100.0); test1->SetSpacing(space);
>
> // Change Image resolution in the function
>
> image_resize_filter<ImageType>(test1);
> }
>
> Now after running this program it does not increase the size of the image .
> It would be very helpful if someone could point out the mistake in that....
>
>
>
> --
> View this message in context:
> http://old.nabble.com/Passing-itk-images-to-functions-tp29830622p29830622.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101017/60fda232/attachment-0001.htm>


More information about the Insight-users mailing list