<!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 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>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>flydps</SPAN></DIV></BODY></HTML>