<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">Hi,<div>Thank you for your help with the Filter,still, I run into some other problems.</div><div>My source file is below:</div><div><br></div><div><div><div>typedef itk::Image&lt; unsigned char, &nbsp;2 &gt; &nbsp; InputImageType;</div><div>typedef itk::Image&lt; double, 2 &gt; &nbsp; ImageType2D;</div><div>typedef itk::Image&lt; double, 3 &gt; &nbsp; ImageType3D;</div><div>typedef itk::ImageFileReader&lt; InputImageType &gt; ReaderType;</div><div>typedef itk::JoinSeriesImageFilter&lt;ImageType2D, ImageType3D&gt; JoinSeriesImageFilterType;</div><div>typedef itk::CastImageFilter&lt;InputImageType,ImageType2D&gt; &nbsp;ImageTypecast;&nbsp;</div><div>&nbsp; int main()</div><div>{</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;ReaderType::Pointer reader = ReaderType::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;ImageTypecast::Pointer toReal = ImageTypecast::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;JoinSeriesImageFilterType::Pointer joinFilter = JoinSeriesImageFilterType::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;joinFilter-&gt;SetOrigin(0.0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; joinFilter-&gt;SetSpacing(1.0);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp;int slice;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char* Src="D:\\ITK_test\\joinseriesfilter\\bin\\liimage";</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char* Des="D:\\ITK_test\\joinseriesfilter\\bin\\testfigure1";</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char* Ipo="_cor.tif";</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char* Ipr="GFP_";</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char* filename = new char[100];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>char* writenname=new char[100];</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>for(slice=3584;slice&lt;3586;++slice)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>{<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>filename[0] = '\0';</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>sprintf_s(filename,100,"%s\\%s%05d%s",Src,Ipr,slice,Ipo);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>reader-&gt;SetFileName(filename);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>try</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>reader-&gt;Update();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>catch ( itk::ExceptionObject &amp;err)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>std::cout &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl;&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>std::cout &lt;&lt; err &lt;&lt; std::endl;&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>return -1;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>toReal-&gt;SetInput( reader-&gt;GetOutput() );</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>toReal-&gt;Update();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>std::cout&lt;&lt;toReal-&gt;GetOutput()-&gt;GetBufferedRegion()&lt;&lt;'\t';//test whether we can get input</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>joinFilter-&gt;SetInput(slice,toReal-&gt;GetOutput());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> &nbsp;try</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>joinFilter-&gt;Update();//when Update we&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span> &nbsp;catch( itk::InvalidRequestedRegionError &amp; err )</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>std::cout &lt;&lt; err &lt;&lt; std::endl;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div></div><div><br></div><div><br></div><div>IT's quite simple code ,however ,when I debug it I run into a problem like this,</div><div><img src="cid:203fdf4a$1$14162b87281$Coremail$swingsw89$163.com"></div><div><br></div><div>I don' know how this error came out ? Thank you!</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                                                                                </span>shiwei</div><div><br></div><br><br><br><br><div></div><div id="divNeteaseMailCard"></div><br>At 2013-09-26 23:40:38,"Bradley&nbsp;Lowekamp"&nbsp;&lt;blowekamp@mail.nih.gov&gt; wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello,<div><br></div><div>What is the error you are getting? Is it runtime or compilation time?</div><div><br></div><div>Here is the internal execute method from SimpleITK, I hope it's straight forward enough for an example:</div><div><br></div><div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">template &lt;class TImageType&gt;</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">Image JoinSeriesImageFilter::ExecuteInternal ( const std::vector&lt;Image&gt; &amp;images )</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">{</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; // Define the input and output image types</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; typedef TImageType &nbsp; &nbsp; InputImageType;</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; //Define output image type</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; typedef typename InputImageType::template Rebind&lt;typename InputImageType::PixelType, InputImageType::ImageDimension+1&gt;::Type OutputImageType;</span></font></div><div><br></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; typedef itk::JoinSeriesImageFilter&lt;InputImageType, &nbsp;OutputImageType&gt; FilterType;</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; // Set up the ITK filter</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; typename FilterType::Pointer filter = FilterType::New();</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;"><br></span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; for ( unsigned int i = 0; i &lt; images.size(); ++i )</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; {</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; // Get the pointer to the ITK image contained in image1</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; typename InputImageType::ConstPointer image = this-&gt;CastImageToITK&lt;InputImageType&gt;( images[i] );</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;"><br></span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; filter-&gt;SetInput( i, image );</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; }</span></font></div><div><br></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; filter-&gt;SetOrigin ( this-&gt;m_Origin );</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; filter-&gt;SetSpacing ( this-&gt;m_Spacing );</span></font></div><div><br></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; if (this-&gt;GetDebug())</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; &nbsp;{</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; &nbsp;std::cout &lt;&lt; "Executing ITK filter:" &lt;&lt; std::endl;</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; &nbsp;std::cout &lt;&lt; filter;</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; &nbsp; &nbsp;}</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;"><br></span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; // Run the ITK filter and return the output as a SimpleITK image</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; filter-&gt;Update();</span></font></div><div><br></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; typename FilterType::OutputImageType *itkOutImage = filter-&gt;GetOutput();</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; this-&gt;FixNonZeroIndex( itkOutImage );</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp; return Image( itkOutImage );</span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 15px;">&nbsp;}</span></font></div></div><div><br></div><div><br></div><div>Good luck,</div><div>Brad</div><div><br><div><div>On Sep 26, 2013, at 11:03 AM, shiwei &lt;<a href="mailto:swingsw89@163.com">swingsw89@163.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="line-height: 1.7; font-size: 14px; font-family: arial; ">Hi!<div>&nbsp; &nbsp;I stil have a problem when using the "iitkJoinImageFilter".</div><div>&nbsp; Here is the thing:</div><div>&nbsp;&nbsp;&nbsp;typedef itk::Image&lt; double, 2 &gt; &nbsp; ImageType2D; &nbsp;// defying the Readertype,they are 2D slices</div><div>&nbsp; &nbsp;typedef itk::Image&lt; double,3 &gt; &nbsp; &nbsp;ImageType3D; // the 3D volume which I want to get from the JoinImageFilter</div><div><br></div><div>&nbsp; As I read a series of 2D slices with a "for" loop,then after processing them , I use JoinImageFilter to get a 3D output, then I had a problem:</div><div><br></div><div>&nbsp;typedef itk::JoinImageFilter&lt;ImageType2D, ImageType3D&gt; JoinImageFilterType;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;JoinImageFilterType::Pointer joinFilter = JoinImageFilterType::New();</div><div><br></div><div>&nbsp; for(int slice=0;slice&lt;10,slice++)</div><div>{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.........read the 2D slice...........</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;..........processing............</div><div>&nbsp; &nbsp; &nbsp; &nbsp; ...........2D output Image......</div><div>&nbsp; &nbsp; joinFilter-&gt;SetInput(slice,outputImage);</div><div>}</div><div>&nbsp;joinFilter-&gt;update;</div><div><br></div><div>But after I did this ,vs comes out an error says itk can't convert from 2D to 3D, &nbsp;If it's convienient can you show me an example like this with the&nbsp;<span style="line-height: 1.7;">"iitkJoinImageFilter"? To show me how to make this right? Thank you! Also,if I want to test whether I get a proper 3D volume,what shall I do then?&nbsp;</span></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div><br><br><br><br><div></div><div></div><br>At 2013-09-25 14:23:27,shiwei&nbsp;&lt;<a href="mailto:swingsw89@163.com">swingsw89@163.com</a>&gt; wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div style="line-height: 1.7; font-size: 14px; font-family: arial; ">Thank you very much! Brad!<div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;shiwei<br><br><br><br><br><div></div><div></div><br>At 2013-09-25 00:00:50,"Bradley&nbsp;Lowekamp"&nbsp;&lt;<a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a>&gt; wrote:<br> <blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><div>Hello,</div><div><br></div><div>To join a series of 2D image into a 3D volume you can you the JoinImageFilter:</div><div><a href="http://www.itk.org/Insight/Doxygen/html/classitk_1_1JoinImageFilter.html">http://www.itk.org/Insight/Doxygen/html/classitk_1_1JoinImageFilter.html</a></div><div><br></div><div>The extract a 2D image from a 3D volume you can use the ExtractImageFilter:</div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html">http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html</a></div><div><br></div><div>To extract a 3D volume from a 3D volume there are a few filter:</div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html">http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html</a></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html">http://www.itk.org/Doxygen/html/classitk_1_1RegionOfInterestImageFilter.html</a></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1CropImageFilter.html">http://www.itk.org/Doxygen/html/classitk_1_1CropImageFilter.html</a></div><div><br></div><div>Hope that helps,</div><div>Brad</div><br><div><div>On Sep 24, 2013, at 11:14 AM, shiwei &lt;<a href="mailto:swingsw89@163.com">swingsw89@163.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="line-height: 1.7; font-size: 14px; font-family: arial; ">Hi,all~<div><span class="Apple-tab-span" style="white-space:pre">        </span>As I first read a 3D Image Volume slice by slice,then after processing each slice I need to change them to a 3D volume for further processing, However,<b> I can't use&nbsp;itk::ImageSeriesReader</b> for my pixeltype now is double and it takes to much time to write out the 2D image first.</div><div>&nbsp; &nbsp; &nbsp; &nbsp;I wonder if there is a class to help me read the 2D slices directly to 3D volume just in the memory.Also, I still eager to know whether there is a class can direclty extract a part of 3D volume from a bigger one.Beacuse IF there is no way to deal with that ,I will have to change all the 2D images to 2D Array then combine them to 3D Array which I think may take a lot of time.</div><div>&nbsp; &nbsp; &nbsp; &nbsp;Do you have any way to figure this out? Thank you all !</div></div><br><br><span title="neteasefoote
 r"><span id="netease_mail_footer"></span></span>_____________________________________<br>Powered by <a href="http://www.kitware.com/">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></blockquote></div><br></blockquote></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span></blockquote></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span></blockquote></div><br></div></blockquote></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>