<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<T_Image> 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"><<a href="mailto:flydps@163.com" target="_blank">flydps@163.com</a>></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 "pReader"
to my sub-function "OutputOldImageWidth"? </div>
<div> </div>
<div> </div>
<div>
<div> </div>
<div> </div>
<div>#include "itkImage.h"</div>
<div>#include "itkImageFileReader.h"</div>
<div>#include "itkImageFileWriter.h"</div>
<div> </div>
<div>#include <iostream></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& inputRegion = </div>
<div> pReader->GetOutput()->GetLargestPossibleRegion();</div>
<div> const T_Image::SizeType& vnInputSize = inputRegion.GetSize();</div>
<div> unsigned int nOldWidth = vnInputSize[0];</div>
<div> unsigned int nOldHeight = vnInputSize[1];</div>
<div> printf("\nThe old width of image is %d",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 << "Usage: "</div>
<div> << std::endl</div>
<div> << argv[0]</div>
<div> << " inputImageFile outputImageFile "</div>
<div> << std::endl;</div>
<div> </div>
<div> return EXIT_FAILURE;</div>
<div> }</div>
<div> </div>
<div> // Typedef'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<T_InputPixel, 2> T_Image;</div>
<div> typedef itk::ImageFileReader<T_Image> T_Reader;</div>
<div> typedef unsigned char T_WritePixel;</div>
<div> typedef itk::Image<T_WritePixel, 2> T_WriteImage;</div>
<div> typedef itk::ImageFileWriter<T_WriteImage> 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->SetFileName( argv[1] );</div>
<div> pReader->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->SetFileName(argv[2]);</div>
<div> pWriter->SetInput(pReader->GetOutput());</div>
<div> pWriter->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>