<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I prefer to use a template function like this:<div><div>template <class PixelType, unsigned int Dimension> int DoIt(itk::SmartPointer<PixelType,Dimension> img)</div><div>or </div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><font class="Apple-style-span" face="Helvetica" size="3">template<class TImage> int DoIt(itk::SmartPointer<TImage> img)</font></div></div><div><br></div><div>and inside the function creates the propers typedef using the dimension and pixel type of the template for example.</div><div><br></div><div>I hate use a global typedef but if you want to use them, you need to move the typedef how say Dženan Zukić.</div><div><br></div><div><br></div><div>Saludos</div><div><div apple-content-edited="true"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">__________________________________<br><font class="Apple-style-span" color="#b7bfc5">|</font> Ariel Hernán Curiale Ph.D Student<br><font class="Apple-style-span" color="#b7bfc5">|</font> ETSI Telecomunicación<br><font class="Apple-style-span" color="#b7bfc5">|</font> Universidad de Valladolid<br><font class="Apple-style-span" color="#b7bfc5">|</font> Campus Miguel Delibes<br><font class="Apple-style-span" color="#b7bfc5">|</font> 47011 Valladolid, Spain<br><font class="Apple-style-span" color="#b7bfc5">|</font> Phone: 983-423000 ext. 5590</div><div><font class="Apple-style-span" color="#b7b7b7" style="font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">|</font> Web: <a href="http://www.curiale.com.ar/"><font class="Apple-style-span" color="#084ebe">www.curiale.com.ar</font></a><br><font class="Apple-style-span" color="#b7b7b7" style="font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; ">|</font><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; font-weight: normal; font-style: normal; color: rgb(0, 0, 0); ">_________________________________</span></div></div></div></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></div>
</div>
<br><div><div>El 29/10/2012, a las 10:55, Dženan Zukić escribió:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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>
_____________________________________<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>http://www.kitware.com/products/protraining.php<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></div></div></body></html>