<div>Luis,</div>
<div>&nbsp;</div>
<div>Just after I sent the email, I&nbsp;managed to run&nbsp;it with no errors, but&nbsp;I can&#39;t have the right resulting image anyway. Here is the code:<br><br>
<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"> &lt; 2D</font><font color="#005032" size="2">
 ImageType</font><font size="2">, 3D</font><font color="#005032" size="2">ImageType</font><font size="2"> &gt; </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">&lt; 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"> &gt; </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-&gt;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-&gt;</p></font><font color="#005032" size="2">SetDestinationImage</font><font size="2">(image);<br>filterP-&gt;</font><font color="#005032" size="2">SetInput</font><font size="2">(image);</font></div>

<p align="left"><font size="2"></font></p>
<div><font size="2"><b><font color="#7f0055">for</font></b> (<b><font color="#7f0055">int</font></b> i=0; i&lt;numSlices; i++)<br>{<br>&nbsp;{some processing&nbsp;using the ith slice} <br>&nbsp;start[2] = i;<br>&nbsp;filter2D-&gt;<b><font color="#642880">
Update</font></b>();<br>&nbsp;filterCast-&gt; <font color="#005032">SetInput</font>(filter2D-&gt;<font color="#005032">GetOutput</font>());<br>&nbsp;filterCast-&gt;<b><font color="#642880"> Update</font></b>();&nbsp;<br><font size="2">&nbsp;
outputRegion.SetIndex( start ); </font></font></div>
<div><font size="2">&nbsp;outputRegion = filterCast-&gt;<font color="#005032">GetOutput</font>()-&gt;<font size="2">GetRequestedRegion</font>();<br>&nbsp;filterP-&gt;<font color="#005032">SetSourceImage</font>(filterCast-&gt;<font color="#005032">
GetOutput</font> ());<br>&nbsp;filterP-&gt;<font color="#005032">SetDestinationIndex</font>(start);<br>&nbsp;filterP-&gt;<font color="#005032">SetSourceRegion </font>(outputRegion);<br>&nbsp;filterP-&gt;<b><font color="#642880">Update</font>
</b>();<br>} </font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">When I see the filterP-&gt;getOutput() the result is exactly the same as the filterP Input and Destination (which are the same image). And the processing in the slice&nbsp;certainly change the image.</font>
</div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">Thank you again,</font></div>
<div><font size="2"></font>&nbsp;</div>
<div><font size="2">Dário Oliveira.</font></div>
<div><font size="2"></font>&nbsp;</div></div>
<div><span class="gmail_quote">2007/9/8, Dário Oliveira &lt;<a href="mailto:dariodisk@gmail.com">dariodisk@gmail.com</a>&gt;:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Hi Luis,</div>
<div>&nbsp;</div>
<div>thank you for your reply.</div>
<div>&nbsp;</div>
<div>Yes, I&#39;m using the PasteImageFilter and I&#39;ve tried two different approaches:</div>
<div>&nbsp;</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">&lt; </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"> &gt; </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-&gt;</p></font><font color="#005032" size="2">SetDestinationImage</font><font size="2">(image3D);<br>filterP-&gt;</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&lt;numSlices; i++)<br>{<br>&nbsp;{some processing&nbsp;using the ith slice} 
</font><font size="2"><br><font size="2">&nbsp;filterP-&gt;</font><font color="#005032" size="2">SetSourceImage</font><font size="2">(filter2D-&gt;</font><font color="#005032" size="2">GetOutput</font><font size="2">());<br>&nbsp;filterP-&gt; 
</font><font color="#005032" size="2">SetDestinationIndex</font><font size="2">(start);<br></font><font size="2">&nbsp;filterP-&gt;</font><font color="#005032" size="2">SetSourceRegion</font><font size="2">(filter2D-&gt;</font>
 <font color="#005032" size="2">GetOutput</font><font size="2">()-&gt;GetLargestPossibleRegion());<br></font><font size="2">&nbsp;filterP-&gt;</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>&nbsp;</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"> &lt; 2D</font><font color="#005032" size="2">
 ImageType</font><font size="2">, 3D</font><font color="#005032" size="2">ImageType</font><font size="2"> &gt; </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">&lt; 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"> &gt; </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-&gt;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-&gt;</p></font><font color="#005032" size="2">SetDestinationImage</font><font size="2">(image);<br>filterP-&gt;</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&lt;numSlices; i++)<br>{<br>&nbsp;{some processing&nbsp;using the ith slice} 
<br>&nbsp;<font size="2">start[2] = i;</font><font size="2"><br></font></font><font size="2">&nbsp;filter2D-&gt;</font><b><font color="#642880" size="2">Update</font></b><font size="2">();<br>&nbsp;</font><font size="2">filterCast-&gt;</font>
 <font color="#005032" size="2">SetInput</font><font size="2">(filter2D-&gt;</font><font color="#005032" size="2">GetOutput</font><font size="2">());<br>&nbsp;</font><font size="2">filterCast-&gt;</font><b><font color="#642880" size="2">
 Update</font></b><font size="2">(); <br>&nbsp;</font><font size="2">outputRegion = filterCast-&gt;</font><font color="#005032" size="2">GetOutput</font><font size="2">()-&gt;GetLargestPossibleRegion();<br>&nbsp;</font><font size="2">
 outputRegion.SetIndex( start ); <br>&nbsp;</font><font size="2">filterP-&gt;</font><font color="#005032" size="2">SetSourceImage</font><font size="2">(filterCast-&gt;</font><font color="#005032" size="2">GetOutput</font><font size="2">
 ());<br>&nbsp;</font><font size="2">filterP-&gt;</font><font color="#005032" size="2">SetDestinationIndex</font><font size="2">(start);<br>&nbsp;</font><font size="2">filterP-&gt;</font><font color="#005032" size="2">SetSourceRegion 
</font><font size="2">(outputRegion);<br></font><font size="2">&nbsp;filterP-&gt;</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 &quot;<font size="2">filterP-&gt;<b><font color="#642880">Update</font></b></font></font><font size="2">();&quot;</font></p>
<p align="left">I&#39;ve&nbsp;just started to work&nbsp;with ITK, so I&#39;m probably making some&nbsp;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 &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>&gt;:</span> 
<div><span class="e" id="q_114e5ba9ab309ca1_1">
<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 &quot;PasteImageFilter&quot; ?<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html" target="_blank">
http://www.itk.org/Insight/Doxygen/html/classitk_1_1PasteImageFilter.html</a><br><br><br>2) When you say that &quot;it doesn&#39;t seem to work&quot; ?<br>&nbsp;&nbsp; Do you mean that<br><br>&nbsp;&nbsp; a) It doesn&#39;t compile ?<br>&nbsp;&nbsp; b) It doesn&#39;t link ? 
<br>&nbsp;&nbsp; c) It produces a segmentation fault at run time ?<br>&nbsp;&nbsp; d) It throws an exception at run time ?<br>&nbsp;&nbsp; e) It produces an image that when you visualize<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;doesn&#39;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>&nbsp;&nbsp; Thanks<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Luis<br><br><br><br>-----------------------<br>Dário Oliveira wrote:<br>&gt; Hi friends,<br>&gt;<br>&gt; I&#39;m having trouble to paste (actually replace) a processed 2D slice into 
<br>&gt; its original volume. I&#39;ve read some previous itk-users email in the<br>&gt; mailing list, but I still couldn&#39;t manage to suceed. Is there any simple<br>&gt; way to perfom this task?<br>&gt;<br>&gt; I&#39;m trying to cast the processed 2D image to a 3D one, and get its 3D 
<br>&gt; region to paste into the original 3D volume, but it doesn&#39;t seem to work.<br>&gt;<br>&gt; Any help will be very apreciated,<br>&gt;<br>&gt; Regards<br>&gt; --<br>&gt; Dário Oliveira<br>&gt;<br>&gt;<br>&gt; ------------------------------------------------------------------------ 
<br>&gt;<br>&gt; _______________________________________________<br>&gt; Insight-users mailing list<br>&gt; <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org
</a><br>&gt; <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br></blockquote></span>
</div></div><br><br clear="all"><br>-- <br><span class="sg">Dário Oliveira </span></blockquote></div><br><br clear="all"><br>-- <br>Dário Oliveira