[Insight-users] Iterators problem

Jeremy Lecoeur jeremy.j.lecoeur at vanderbilt.edu
Thu Oct 21 11:48:48 EDT 2010


  Thanks for the advice but it did not change a thing. I still have the 
same scrambled output.

Jeremy

On 21/10/2010 10:22, Yang, Jinzhong wrote:
> You should set the requested region for the output image:
>
> RealIteratorType iteratorlambda1( imagelambda1,
> imagelambda1->GetRequestedRegion() );
>
> -----Original Message-----
> From: insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org]
> On Behalf Of Jeremy Lecoeur
> Sent: Wednesday, October 20, 2010 5:39 PM
> To: insight-users at itk.org
> Subject: [Insight-users] Iterators problem
>
>    In the project I'm working on, I need to take value from an image
> (named imagex) which data type is short and apply some complicated
> mathematical function. The results of this function is a double and is
> store in an image (named imagelambda1) which data type is double.
> When I'm using iterator to traverse the first image (imagex) and want to
> write the result in imagelambda1, it seems that the resulting image is
> scrambled.
>
> Here is the portion of the code I use :
>
> typedef short PixelType;
> typedef double  RealPixelType;
> const unsigned int Dimension = 3;
> typedef itk::Image<  PixelType, Dimension>  ImageType;
> typedef itk::Image<  RealPixelType, Dimension>     RealImageType;
> typedef itk::ImageRegionIterator<  ImageType>  IteratorType;
> typedef itk::ImageRegionIterator<  RealImageType>  RealIteratorType;
>
>
> IteratorType iteratorx( imagex, imagex->GetRequestedRegion() );
> RealIteratorType iteratorlambda1( imagelambda1,
> imagex->GetRequestedRegion() );
>
> for (iteratorx.GoToBegin(), iteratorlambda1.GoToBegin();
> !iteratorx.IsAtEnd(); ++iteratorx, ++iteratorlambda1){
>                   iteratorlambda1.Set( some_function(iteratorx.Get()));
> }
>
> The following link to an image show the input image (bottom) and result
> (top)when I'm just copying the input (i.e.
> iteratorlambda1.Set(iteratorx.Get()); ). I'm using the copy so it's
> easier to see that everything is scrambled.
>
> http://img28.imageshack.us/img28/3628/55031279.png
>
> I don't really understand what's happening.
>
> Jeremy
> _____________________________________
> 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
>


-- 
Jeremy Lecoeur, Ph.D.
Research Associate
Vanderbilt University
Email: jeremy.j.lecoeur at vanderbilt.edu



More information about the Insight-users mailing list