<div dir="ltr">Fabian,<div><br></div><div>You can use  itk::ImageIOFactory::CreateImageIO  to create an IO object that will read metadata about your image, for example it will have a GetNumberOfDimensions method.</div><div>

<br></div><div>You'll have to specialize your template instantiations on the dimensions you need then.</div><div><br></div><div>e.g., something like:</div><div><br></div><div>auto imageIO = itk::ImageIOFactory::CreateImageIO(filename,itk::ImageIOFactory::ReadMode);<br>

</div><div><div>imageIO->SetFileName(filename);</div><div>imageIO->ReadImageInformation();</div></div><div>auto dimensions =  imageIO->GetNumberOfDimensions();</div><div><br></div><div><div>switch (dimensions)</div>

<div>{</div><div>  case 2:</div><div><span style="white-space:pre">     </span>SwitchOnComponent<2U>(config, identity, info);</div><div><span style="white-space:pre">     </span>break;</div><div>  case 3:</div><div>

SwitchOnComponent<3U>(config, identity, info);</div><div><span class="" style="white-space:pre">                    </span>break;</div></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Mon, Mar 3, 2014 at 1:32 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;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="HOEnZb"><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>