<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
BODY {
        LINE-HEIGHT: 1.5; FONT-FAMILY: Î¢ÈíÑźÚ; COLOR: #000000; FONT-SIZE: 10.5pt
}
</STYLE>

<META name=GENERATOR content="MSHTML 9.00.8112.16450"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi, friends!</DIV>
<DIV>I am trying to write sub function with Itk. But I am puzzled by how&nbsp;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&nbsp; "pReader" 
to my sub-function "OutputOldImageWidth"? </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#include&nbsp;"itkImage.h"</DIV>
<DIV>#include&nbsp;"itkImageFileReader.h"</DIV>
<DIV>#include&nbsp;"itkImageFileWriter.h"</DIV>
<DIV>&nbsp;</DIV>
<DIV>#include&nbsp;&lt;iostream&gt;</DIV>
<DIV>//Subfuntion&nbsp;to&nbsp;get&nbsp;image&nbsp;width</DIV>
<DIV>void&nbsp;OutputOldImageWidth(T_Reader::Pointer&nbsp;pReader);</DIV>
<DIV>&nbsp;</DIV>
<DIV>void&nbsp;OutputOldImageWidth(T_Reader::Pointer&nbsp;pReader)</DIV>
<DIV>{</DIV>
<DIV>&nbsp;&nbsp;const&nbsp;T_Image::RegionType&amp;&nbsp;inputRegion&nbsp;=&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pReader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();</DIV>
<DIV>&nbsp;&nbsp;const&nbsp;T_Image::SizeType&amp;&nbsp;vnInputSize&nbsp;=&nbsp;inputRegion.GetSize();</DIV>
<DIV>&nbsp;&nbsp;unsigned&nbsp;int&nbsp;nOldWidth&nbsp;=&nbsp;vnInputSize[0];</DIV>
<DIV>&nbsp;&nbsp;unsigned&nbsp;int&nbsp;nOldHeight&nbsp;=&nbsp;vnInputSize[1];</DIV>
<DIV>&nbsp;&nbsp;printf("\nThe&nbsp;old&nbsp;width&nbsp;of&nbsp;image&nbsp;is&nbsp;%d",nOldWidth);</DIV>
<DIV>&nbsp;}</DIV>
<DIV>/////////////////////////////////////</DIV>
<DIV>&nbsp;</DIV>
<DIV>int&nbsp;main(&nbsp;int&nbsp;argc,&nbsp;char&nbsp;*&nbsp;argv[]&nbsp;)</DIV>
<DIV>{</DIV>
<DIV>&nbsp;&nbsp;if(&nbsp;argc&nbsp;!=&nbsp;3&nbsp;)&nbsp;</DIV>
<DIV>&nbsp;&nbsp;{&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;std::cerr&nbsp;&lt;&lt;&nbsp;"Usage:&nbsp;"</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;argv[0]</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;"&nbsp;inputImageFile&nbsp;outputImageFile&nbsp;"</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt;&nbsp;std::endl;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;EXIT_FAILURE;</DIV>
<DIV>&nbsp;&nbsp;}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;//&nbsp;Typedef's&nbsp;for&nbsp;pixel,&nbsp;image,&nbsp;reader&nbsp;and&nbsp;writer&nbsp;types</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;unsigned&nbsp;char&nbsp;T_InputPixel;</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;unsigned&nbsp;char&nbsp;T_OutputPixel;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;itk::Image&lt;T_InputPixel,&nbsp;2&gt;&nbsp;T_Image;</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;itk::ImageFileReader&lt;T_Image&gt;&nbsp;T_Reader;</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;unsigned&nbsp;char&nbsp;T_WritePixel;</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;itk::Image&lt;T_WritePixel,&nbsp;2&gt;&nbsp;T_WriteImage;</DIV>
<DIV>&nbsp;&nbsp;typedef&nbsp;itk::ImageFileWriter&lt;T_WriteImage&gt;&nbsp;T_Writer;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;//&nbsp;Prepare&nbsp;the&nbsp;reader&nbsp;and&nbsp;update&nbsp;it&nbsp;right&nbsp;away&nbsp;to&nbsp;know&nbsp;the&nbsp;sizes&nbsp;beforehand.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;T_Reader::Pointer&nbsp;pReader&nbsp;=&nbsp;T_Reader::New();</DIV>
<DIV>&nbsp;&nbsp;pReader-&gt;SetFileName(&nbsp;argv[1]&nbsp;);</DIV>
<DIV>&nbsp;&nbsp;pReader-&gt;Update();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;//******************&nbsp;Call&nbsp;subfunction&nbsp;to&nbsp;get&nbsp;the&nbsp;image&nbsp;width.</DIV>
<DIV>&nbsp;OutputOldImageWidth(T_Reader::Pointer&nbsp;pReader)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;//&nbsp;Write&nbsp;the&nbsp;result</DIV>
<DIV>&nbsp;&nbsp;T_Writer::Pointer&nbsp;pWriter&nbsp;=&nbsp;T_Writer::New();</DIV>
<DIV>&nbsp;&nbsp;pWriter-&gt;SetFileName(argv[2]);</DIV>
<DIV>&nbsp;&nbsp;pWriter-&gt;SetInput(pReader-&gt;GetOutput());</DIV>
<DIV>&nbsp;&nbsp;pWriter-&gt;Update();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;return&nbsp;EXIT_SUCCESS;</DIV>
<DIV>}</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN>Thank you!</SPAN></DIV>
<DIV><SPAN></SPAN>&nbsp;</DIV>
<DIV><SPAN>flydps</SPAN></DIV></BODY></HTML>