<font><font face="verdana,sans-serif">typedef must come before its use, that is before function. You should make it just after all the includes.</font></font><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)"> typedef itk::</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)">ImageFileReader&lt;T_Image&gt; T_</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:15px;background-color:rgb(255,255,255)">Reader;</span><font><font face="verdana,sans-serif"><br>

</font></font><br><div class="gmail_quote">On Sat, Oct 27, 2012 at 6:48 PM, flydps <span dir="ltr">&lt;<a href="mailto:flydps@163.com" target="_blank">flydps@163.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<u></u>





<div style="MARGIN:10px">
<div>Hi, friends!</div>
<div>I am trying to write sub function with Itk. But I am puzzled by how to 
get the Itk typedef parameters for the sub-function. The function I want to 
realize is as follow, but how can I transfer the information of  &quot;pReader&quot; 
to my sub-function &quot;OutputOldImageWidth&quot;? </div>
<div> </div>
<div> </div>
<div> 
<div> </div>
<div> </div>
<div>#include &quot;itkImage.h&quot;</div>
<div>#include &quot;itkImageFileReader.h&quot;</div>
<div>#include &quot;itkImageFileWriter.h&quot;</div>
<div> </div>
<div>#include &lt;iostream&gt;</div>
<div>//Subfuntion to get image width</div>
<div>void OutputOldImageWidth(T_Reader::Pointer pReader);</div>
<div> </div>
<div>void OutputOldImageWidth(T_Reader::Pointer pReader)</div>
<div>{</div>
<div>  const T_Image::RegionType&amp; inputRegion = </div>
<div>                              pReader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();</div>
<div>  const T_Image::SizeType&amp; vnInputSize = inputRegion.GetSize();</div>
<div>  unsigned int nOldWidth = vnInputSize[0];</div>
<div>  unsigned int nOldHeight = vnInputSize[1];</div>
<div>  printf(&quot;\nThe old width of image is %d&quot;,nOldWidth);</div>
<div> }</div>
<div>/////////////////////////////////////</div>
<div> </div>
<div>int main( int argc, char * argv[] )</div>
<div>{</div>
<div>  if( argc != 3 ) </div>
<div>  { </div>
<div>    std::cerr &lt;&lt; &quot;Usage: &quot;</div>
<div>              &lt;&lt; std::endl</div>
<div>              &lt;&lt; argv[0]</div>
<div>              &lt;&lt; &quot; inputImageFile outputImageFile &quot;</div>
<div>              &lt;&lt; std::endl;</div>
<div> </div>
<div>    return EXIT_FAILURE;</div>
<div>  }</div>
<div> </div>
<div>  // Typedef&#39;s for pixel, image, reader and writer types</div>
<div>  typedef unsigned char T_InputPixel;</div>
<div>  typedef unsigned char T_OutputPixel;</div>
<div> </div>
<div>  typedef itk::Image&lt;T_InputPixel, 2&gt; T_Image;</div>
<div>  typedef itk::ImageFileReader&lt;T_Image&gt; T_Reader;</div>
<div>  typedef unsigned char T_WritePixel;</div>
<div>  typedef itk::Image&lt;T_WritePixel, 2&gt; T_WriteImage;</div>
<div>  typedef itk::ImageFileWriter&lt;T_WriteImage&gt; T_Writer;</div>
<div> </div>
<div> </div>
<div>  // Prepare the reader and update it right away to know the sizes beforehand.</div>
<div> </div>
<div>  T_Reader::Pointer pReader = T_Reader::New();</div>
<div>  pReader-&gt;SetFileName( argv[1] );</div>
<div>  pReader-&gt;Update();</div>
<div> </div>
<div>  </div>
<div>  //****************** Call subfunction to get the image width.</div>
<div> OutputOldImageWidth(T_Reader::Pointer pReader)</div>
<div> </div>
<div> </div>
<div>  // Write the result</div>
<div>  T_Writer::Pointer pWriter = T_Writer::New();</div>
<div>  pWriter-&gt;SetFileName(argv[2]);</div>
<div>  pWriter-&gt;SetInput(pReader-&gt;GetOutput());</div>
<div>  pWriter-&gt;Update();</div>
<div> </div>
<div>  return EXIT_SUCCESS;</div>
<div>}</div></div>
<div> </div>
<div><span>Thank you!</span></div><span class="HOEnZb"><font color="#888888">
<div><span></span> </div>
<div><span>flydps</span></div></font></span></div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">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" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>