<div>Hi Luis,</div>
<div> </div>
<div>thank you for your reply.</div>
<div> </div>
<div>Yes, I'm using the PasteImageFilter and I've tried two different approaches:</div>
<div> </div>
<div>1. To define the filter with an 2D image as source and a 3D image as the other input, just like that:</div>
<div><b><font color="#7f0055" size="2"><br>typedef</font></b><font size="2"> itk::</font><font color="#005032" size="2">PasteImageFilter</font><font size="2">< </font><font color="#005032" size="2">3DImageType</font><font size="2">
, 2D</font><font color="#005032" size="2">ImageType</font><font size="2">, </font><font color="#005032" size="2">3DImageType</font><font size="2"> > </font><font color="#005032" size="2">FilterTypeP</font><font size="2">
;<br></font><font color="#005032" size="2">FilterTypeP</font><font size="2">::</font><font color="#005032" size="2">Pointer</font><font size="2"> filterP = </font><font color="#005032" size="2">FilterTypeP</font><font size="2">
::New();</font></div>
<div><font size="2">
<p align="left">filterP-></p></font><font color="#005032" size="2">SetDestinationImage</font><font size="2">(image3D);<br>filterP-></font><font color="#005032" size="2">SetInput</font><font size="2">(image3D);</font>
<font size="2"><font size="2">
<p align="left"></p></font><b><font color="#7f0055" size="2">for</font></b></font><font size="2"> (</font><b><font color="#7f0055" size="2">int</font></b><font size="2"> i=0; i<numSlices; i++)<br>{<br> {some processing using the ith slice}
</font><font size="2"><br><font size="2"> filterP-></font><font color="#005032" size="2">SetSourceImage</font><font size="2">(filter2D-></font><font color="#005032" size="2">GetOutput</font><font size="2">());<br> filterP->
</font><font color="#005032" size="2">SetDestinationIndex</font><font size="2">(start);<br></font><font size="2"> filterP-></font><font color="#005032" size="2">SetSourceRegion</font><font size="2">(filter2D-></font>
<font color="#005032" size="2">GetOutput</font><font size="2">()->GetLargestPossibleRegion());<br></font><font size="2"> filterP-></font><b><font color="#642880" size="2">Update</font></b></font><font size="2">();<br>
</font><font size="2">}</font></div>
<div><font size="2">In that approach I got a compile error.</font></div>
<div><font size="2"></font> </div>
<div><font size="2">2. So I changed my approach using a cast image filter, like that:</font></div>
<div><font size="2">
<p align="left"></p></font><b><font color="#7f0055" size="2">typedef</font></b><font size="2"> itk::</font><font color="#005032" size="2">CastImageFilter</font><font size="2"> < 2D</font><font color="#005032" size="2">
ImageType</font><font size="2">, 3D</font><font color="#005032" size="2">ImageType</font><font size="2"> > </font><font color="#005032" size="2">FilterTypeCA</font><font size="2">;<br></font><font color="#005032" size="2">
FilterTypeCA</font><font size="2">::</font><font color="#005032" size="2">Pointer</font><font size="2"> filterCast = </font><font color="#005032" size="2">FilterTypeCA</font><font size="2">::New();
<p align="left"></p>
<p align="left"></p></font><b><font color="#7f0055" size="2">typedef</font></b><font size="2"> itk::</font><font color="#005032" size="2">PasteImageFilter</font><font size="2">< 3D</font><font color="#005032" size="2">
ImageType</font><font size="2">, 3D</font><font color="#005032" size="2">ImageType</font><font size="2">, 3D</font><font color="#005032" size="2">ImageType</font><font size="2"> > </font><font color="#005032" size="2">
FilterTypeP</font><font size="2">;<br></font><font color="#005032" size="2">FilterTypeP</font><font size="2">::</font><font color="#005032" size="2">Pointer</font><font size="2"> filterP = </font><font color="#005032" size="2">
FilterTypeP</font><font size="2">::New();
<p align="left"></p>
<p align="left"></p></font><font color="#005032" size="2">3DImageType</font><font size="2">::</font><font color="#005032" size="2">RegionType</font><font size="2"> outputRegion = image->GetLargestPossibleRegion();<br>
</font><font color="#005032" size="2">3DImageType</font><font size="2">::</font><font color="#005032" size="2">SizeType</font><font size="2"> size2 = outputRegion.GetSize();<br></font><font size="2"><font color="#005032" size="2">
3DImageType</font><font size="2">::</font><font color="#005032" size="2">IndexType</font><font size="2"> start = <font size="2">outputRegion</font>.GetIndex();</font><br></font><font size="2">size2[2] = 1;<br>outputRegion.SetSize
( size2 );
<p align="left">filterP-></p></font><font color="#005032" size="2">SetDestinationImage</font><font size="2">(image);<br>filterP-></font><font color="#005032" size="2">SetInput</font><font size="2">(image);</font></div>
<div><font size="2"><font size="2">
<p align="left"></p></font><b><font color="#7f0055" size="2">for</font></b></font><font size="2"> (</font><b><font color="#7f0055" size="2">int</font></b><font size="2"> i=0; i<numSlices; i++)<br>{<br> {some processing using the ith slice}
<br> <font size="2">start[2] = i;</font><font size="2"><br></font></font><font size="2"> filter2D-></font><b><font color="#642880" size="2">Update</font></b><font size="2">();<br> </font><font size="2">filterCast-></font>
<font color="#005032" size="2">SetInput</font><font size="2">(filter2D-></font><font color="#005032" size="2">GetOutput</font><font size="2">());<br> </font><font size="2">filterCast-></font><b><font color="#642880" size="2">
Update</font></b><font size="2">(); <br> </font><font size="2">outputRegion = filterCast-></font><font color="#005032" size="2">GetOutput</font><font size="2">()->GetLargestPossibleRegion();<br> </font><font size="2">
outputRegion.SetIndex( start ); <br> </font><font size="2">filterP-></font><font color="#005032" size="2">SetSourceImage</font><font size="2">(filterCast-></font><font color="#005032" size="2">GetOutput</font><font size="2">
());<br> </font><font size="2">filterP-></font><font color="#005032" size="2">SetDestinationIndex</font><font size="2">(start);<br> </font><font size="2">filterP-></font><font color="#005032" size="2">SetSourceRegion
</font><font size="2">(outputRegion);<br></font><font size="2"> filterP-></font><b><font color="#642880" size="2">Update</font></b><font size="2">();<br>}</font>
<p align="left"><font size="2">In this case I got a runtime error in "<font size="2">filterP-><b><font color="#642880">Update</font></b></font></font><font size="2">();"</font></p>
<p align="left">I've just started to work with ITK, so I'm probably making some silly mistake.</p>
<p align="left">Thank you!</p>
<p align="left">Dário Olivera.</p></div>
<div><span class="gmail_quote">2007/9/8, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br><br>Hi Dario,<br><br>1) Are you using the "PasteImageFilter" ?<br><a href="http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html">
http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html</a><br><br><br>2) When you say that "it doesn't seem to work" ?<br> Do you mean that<br><br> a) It doesn't compile ?<br> b) It doesn't link ?
<br> c) It produces a segmentation fault at run time ?<br> d) It throws an exception at run time ?<br> e) It produces an image that when you visualize<br> doesn't have the content that you expect ?<br><br><br>
3) Could you post to the list the minimal example of your code ?<br><br><br><br> Thanks<br><br><br> Luis<br><br><br><br>-----------------------<br>Dário Oliveira wrote:<br>> Hi friends,<br>><br>> I'm having trouble to paste (actually replace) a processed 2D slice into
<br>> its original volume. I've read some previous itk-users email in the<br>> mailing list, but I still couldn't manage to suceed. Is there any simple<br>> way to perfom this task?<br>><br>> I'm trying to cast the processed 2D image to a 3D one, and get its 3D
<br>> region to paste into the original 3D volume, but it doesn't seem to work.<br>><br>> Any help will be very apreciated,<br>><br>> Regards<br>> --<br>> Dário Oliveira<br>><br>><br>> ------------------------------------------------------------------------
<br>><br>> _______________________________________________<br>> Insight-users mailing list<br>> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>> <a href="http://www.itk.org/mailman/listinfo/insight-users">
http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>Dário Oliveira