<div dir="ltr"><div><div><div><div>Dear Fabian,<br></div>you may solve the issue using a templated filter. The itk::ImageToImageFilter is templated over its input and output image types, which, at the same time, are templated over their pixel type and dimension [1].<br>
<br></div>Thus, if you define your own filter templated over its input/output image types (and ideally, inheriting itk's ImageToImageFilter) you'd be able to specify the type at execution time, when you read your 2D or 3D (even ND) input.<br>
<br></div>In order to know the pixel type and dimensions of an image at execution time, you can get some inspiration from ITK's ReadUnknownImageType example [2].<br><br></div>HTH,<br>JON HAITZ<br><br><div><div>[1] <a href="http://www.itk.org/Doxygen/html/classitk_1_1Image.html">http://www.itk.org/Doxygen/html/classitk_1_1Image.html</a><br>
<div><div><div><div class="gmail_extra">[2] <a href="http://www.itk.org/Wiki/ITK/Examples/IO/ReadUnknownImageType">http://www.itk.org/Wiki/ITK/Examples/IO/ReadUnknownImageType</a><br><br><br><div class="gmail_quote">On 3 March 2014 19:32, Fabian Torres <span dir="ltr"><<a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi all.</div><div><br></div><div>I´m making a filter in ITK for surface enhancement. This filter is an itkImageToImageFilter.</div>
<div><br></div><div>Sometimes I will use this filter with 2D images an sometimes with 3D images. The thing is that inside this filter I have to use some other itk components and I need to specify the number of dimensions  I´m using. So this is a problem since itk does not let me use variables to specify this.</div>

<div><br></div><div>I´m using the next for 3D:</div><div><br></div><div>typedef itk::Vector< PixelType, 3 > VectorPixelType;</div><div>typedef itk::Vector< VectorPixelType,  3 > MatrixPixelType;</div><div>typedef itk::SymmetricSecondRankTensor< PixelType,  3 > TensorPixelType; </div>

<div><br></div><div>typedef itk::Image< TensorPixelType,  3 > TensorImageType;<br></div><div><br></div><div>but I also need to work with 2D and use the same filter.</div><div><br></div><div>Is there a way to know the number of dimensions of the filter input image, and declare the typedefs using this value? </div>
<span class=""><font color="#888888">
<div><br></div><br clear="all"><div><br></div>-- <br>Fabián Torres Robles<br>Maestria en Ciencias en Ingeniería Electrónica<br>Ingeniería en Sistemas Electrónicos<br>tel. 58081280, 0445534661338<br>e-mail <a href="mailto:fabian.trobles@gmail.com" target="_blank">fabian.trobles@gmail.com</a>, <a href="mailto:dae.wong@gmail.com" target="_blank">dae.wong@gmail.com</a>  <div style="line-height:130%;text-align:left;font-size:10px;overflow:hidden;margin-left:0px;word-wrap:break-word;margin-top:0px;padding:0px">

</div><div style="line-height:130%;text-align:left;font-size:10px;overflow:hidden;margin-left:0px;word-wrap:break-word;margin-top:0px;padding:0px"></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></div></div></div></div></div></div>