[ITK Community] [Insight-users] ITK filter dimensions.

Simon Alexander skalexander at gmail.com
Mon Mar 3 13:51:32 EST 2014


Fabian,

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.

You'll have to specialize your template instantiations on the dimensions
you need then.

e.g., something like:

auto imageIO =
itk::ImageIOFactory::CreateImageIO(filename,itk::ImageIOFactory::ReadMode);
imageIO->SetFileName(filename);
imageIO->ReadImageInformation();
auto dimensions =  imageIO->GetNumberOfDimensions();

switch (dimensions)
{
  case 2:
  SwitchOnDimension<2U>(any args you need);
  break;
  case 3:
     SwitchOnDimension<3U>(any args you need);
  break;

 ...
}


and somewhere you have

template <unsigned int Dimension>
void SwitchOnDimension(any args you need)
{
   //something like this
  #typedef itk::Image<double, Dimension> ImageType

 ... etc.
}

Above isn't tested but you get the rough idea.



On Mon, Mar 3, 2014 at 1:46 PM, Simon Alexander <skalexander at gmail.com>wrote:

> Fabian,
>
> 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.
>
> You'll have to specialize your template instantiations on the dimensions
> you need then.
>
> e.g., something like:
>
> auto imageIO =
> itk::ImageIOFactory::CreateImageIO(filename,itk::ImageIOFactory::ReadMode);
> imageIO->SetFileName(filename);
> imageIO->ReadImageInformation();
> auto dimensions =  imageIO->GetNumberOfDimensions();
>
> switch (dimensions)
> {
>   case 2:
>   SwitchOnComponent<2U>(config, identity, info);
>   break;
>   case 3:
>  SwitchOnComponent<3U>(config, identity, info);
> break;
>
>
>
>
>
>
> On Mon, Mar 3, 2014 at 1:32 PM, Fabian Torres <fabian.trobles at gmail.com>wrote:
>
>> Hi all.
>>
>> I´m making a filter in ITK for surface enhancement. This filter is an
>> itkImageToImageFilter.
>>
>> 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.
>>
>> I´m using the next for 3D:
>>
>> typedef itk::Vector< PixelType, 3 > VectorPixelType;
>> typedef itk::Vector< VectorPixelType,  3 > MatrixPixelType;
>> typedef itk::SymmetricSecondRankTensor< PixelType,  3 > TensorPixelType;
>>
>> typedef itk::Image< TensorPixelType,  3 > TensorImageType;
>>
>> but I also need to work with 2D and use the same filter.
>>
>> Is there a way to know the number of dimensions of the filter input
>> image, and declare the typedefs using this value?
>>
>>
>>
>> --
>> Fabián Torres Robles
>> Maestria en Ciencias en Ingeniería Electrónica
>> Ingeniería en Sistemas Electrónicos
>> tel. 58081280, 0445534661338
>> e-mail fabian.trobles at gmail.com, dae.wong at gmail.com
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140303/b42e9b6b/attachment-0002.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list