Hi,<br>I try to use a extract an image slice of a 3D dataset in a function in c++. I read <a href="http://www.itk.org/pipermail/insight-users/2004-November/011095.html">this site</a> where Luis describes how to use an image in a function but I was not able to write my function...<br>
I define the 3D dataset in the main program and want to extract the slice in a function and return this slice somehow back to the main program.<br>At the moment my code looks like<br><br><b><u>main program:</u></b><br> ....<br>
typedef itk::Image<PixelType, 2> OutputImageType; <br> OutputImageType::Pointer outimage;<br> void * pimg = &outimage;<br> extractSlice(pimg, dim);<b><span style="color:rgb(255,0,0)"></span></b><br>
.....<br><br><br><u><b>void extractSlice(void * pimg, int dim)</b></u><br><br> typedef itk::Image<PixelType, 2> OutputImageType; <br> typedef itk::ExtractImageFilter<ImageType, OutputImageType> ExtractFilterType;<br>
ExtractFilterType::Pointer extractFilter = ExtractFilterType::New();<br><br> ... <br><br> OutputImageType::Pointer outimage = OutputImageType::New();<br> <br> try<br> {<br> extractFilter->Update(); <br>
outimage = extractFilter->GetOutput();<br> ImageType::Pointer *kimg = (ImageType::Pointer *)pimg;<br> <b style="color:rgb(255,0,0)"> kimg = outimage.GetPointer();</b> <b> //NOT WORKING</b><br> }<br>
catch(itk::ExceptionObject &err)<br> {<br> ...<br> }<br><br>Does one of you know how to solve my problem?<br>Thanks a lot for your help!<br><br>Best regards<br>melanie<br>