[Insight-users] 2D Slice to 3D Volume

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 13 08:22:35 EDT 2007


Hi Dario,

I'm confused about your last email.

You said:

 > When I see the filterP->getOutput() the result is exactly the same as
 > the filterP Input and Destination (which are the same image). And the
 > processing in the slice certainly change the image.


Do you mean that now the filter works for you ?
or is still not pasting the slice in the destination location ?


    Please let us know,



       Thanks


          Luis



---------------------
Dário Oliveira wrote:
> Luis,
>  
> Just after I sent the email, I managed to run it with no errors, but I 
> can't have the right resulting image anyway. Here is the code:
> 
> *typedef* itk::CastImageFilter < 2D ImageType, 3DImageType > FilterTypeCA;
> FilterTypeCA::Pointer filterCast = FilterTypeCA::New();
> 
> *typedef* itk::PasteImageFilter< 3D ImageType, 3DImageType, 3DImageType 
>  > FilterTypeP;
> FilterTypeP::Pointer filterP = FilterTypeP::New();
> 
> 3DImageType::RegionType outputRegion = image->GetLargestPossibleRegion();
> 3DImageType::SizeType size2 = outputRegion.GetSize();
> 3DImageType::IndexType start = outputRegion.GetIndex();
> size2[2] = 1;
> outputRegion.SetSize ( size2 );
> 
> filterP->
> 
> SetDestinationImage(image);
> filterP->SetInput(image);
> 
> *for* (*int* i=0; i<numSlices; i++)
> {
>  {some processing using the ith slice}
>  start[2] = i;
>  filter2D->* Update*();
>  filterCast-> SetInput(filter2D->GetOutput());
>  filterCast->* Update*(); 
>   outputRegion.SetIndex( start );
>  outputRegion = filterCast->GetOutput()->GetRequestedRegion();
>  filterP->SetSourceImage(filterCast-> GetOutput ());
>  filterP->SetDestinationIndex(start);
>  filterP->SetSourceRegion (outputRegion);
>  filterP->*Update *();
> }
>  
> When I see the filterP->getOutput() the result is exactly the same as 
> the filterP Input and Destination (which are the same image). And the 
> processing in the slice certainly change the image.
>  
> Thank you again,
>  
> Dário Oliveira.
>  
> 2007/9/8, Dário Oliveira <dariodisk at gmail.com 
> <mailto:dariodisk at gmail.com>>:
> 
>     Hi Luis,
>      
>     thank you for your reply.
>      
>     Yes, I'm using the PasteImageFilter and I've tried two different
>     approaches:
>      
>     1. To define the filter with an 2D image as source and a 3D image as
>     the other input, just like that:
>     *
>     typedef* itk::PasteImageFilter< 3DImageType , 2DImageType,
>     3DImageType > FilterTypeP ;
>     FilterTypeP::Pointer filterP = FilterTypeP ::New();
> 
>     filterP->
> 
>     SetDestinationImage(image3D);
>     filterP->SetInput(image3D);
> 
>     *for* (*int* i=0; i<numSlices; i++)
>     {
>      {some processing using the ith slice}
>      filterP->SetSourceImage(filter2D->GetOutput());
>      filterP-> SetDestinationIndex(start);
>      filterP->SetSourceRegion(filter2D->
>     GetOutput()->GetLargestPossibleRegion());
>      filterP->*Update*();
>     }
>     In that approach I got a compile error.
>      
>     2. So I changed my approach using a cast image filter, like that:
> 
>     *typedef* itk::CastImageFilter < 2D ImageType, 3DImageType >
>     FilterTypeCA;
>     FilterTypeCA::Pointer filterCast = FilterTypeCA::New();
> 
>     *typedef* itk::PasteImageFilter< 3D ImageType, 3DImageType,
>     3DImageType > FilterTypeP;
>     FilterTypeP::Pointer filterP = FilterTypeP::New();
> 
>     3DImageType::RegionType outputRegion =
>     image->GetLargestPossibleRegion();
>     3DImageType::SizeType size2 = outputRegion.GetSize();
>     3DImageType::IndexType start = outputRegion.GetIndex();
>     size2[2] = 1;
>     outputRegion.SetSize ( size2 );
> 
>     filterP->
> 
>     SetDestinationImage(image);
>     filterP->SetInput(image);
> 
>     *for* (*int* i=0; i<numSlices; i++)
>     {
>      {some processing using the ith slice}
>      start[2] = i;
>      filter2D->*Update*();
>      filterCast-> SetInput(filter2D->GetOutput());
>      filterCast->* Update*();
>      outputRegion = filterCast->GetOutput()->GetLargestPossibleRegion();
>       outputRegion.SetIndex( start );
>      filterP->SetSourceImage(filterCast->GetOutput ());
>      filterP->SetDestinationIndex(start);
>      filterP->SetSourceRegion (outputRegion);
>      filterP->*Update*();
>     }
> 
>     In this case I got a runtime error in "filterP->*Update*();"
> 
>     I've just started to work with ITK, so I'm probably making
>     some silly mistake.
> 
>     Thank you!
> 
>     Dário Olivera.
> 
>     2007/9/8, Luis Ibanez <luis.ibanez at kitware.com
>     <mailto:luis.ibanez at kitware.com>>:
> 
> 
> 
>         Hi Dario,
> 
>         1) Are you using the "PasteImageFilter" ?
>         http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html
> 
> 
>         2) When you say that "it doesn't seem to work" ?
>            Do you mean that
> 
>            a) It doesn't compile ?
>            b) It doesn't link ?
>            c) It produces a segmentation fault at run time ?
>            d) It throws an exception at run time ?
>            e) It produces an image that when you visualize
>               doesn't have the content that you expect ?
> 
> 
>         3) Could you post to the list the minimal example of your code ?
> 
> 
> 
>            Thanks
> 
> 
>               Luis
> 
> 
> 
>         -----------------------
>         Dário Oliveira wrote:
>>  Hi friends,
>>
>>  I'm having trouble to paste (actually replace) a processed 2D
>         slice into
>>  its original volume. I've read some previous itk-users email
>         in the
>>  mailing list, but I still couldn't manage to suceed. Is there
>         any simple
>>  way to perfom this task?
>>
>>  I'm trying to cast the processed 2D image to a 3D one, and get
>         its 3D
>>  region to paste into the original 3D volume, but it doesn't
>         seem to work.
>>
>>  Any help will be very apreciated,
>>
>>  Regards
>>  --
>>  Dário Oliveira
>>
>>
>>
>         ------------------------------------------------------------------------
> 
>>
>>  _______________________________________________
>>  Insight-users mailing list
>>  Insight-users at itk.org <mailto:Insight-users at itk.org>
>>  http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> 
>     -- 
>     Dário Oliveira 
> 
> 
> 
> 
> -- 
> Dário Oliveira


More information about the Insight-users mailing list