[ITK Community] [Insight-users] Filters Input Image Pixel Type

Mauro Maiorca mauromaiorca at gmail.com
Thu Dec 12 05:58:48 EST 2013


On Thu, Dec 12, 2013 at 9:06 PM, elena bresciani <
elena.bresciani87 at gmail.com> wrote:

> > Ok, thanks but my question was more like How can I know which input
image type requires a particular filter?

ah okay! Any descent of ImageToImageFilter it is meant to support at least
all the native types such as float, char, int, and so on. As all the
classes are templated, so the numeric types are those compatible with your
C++ compiler. However, when you write an image on a file you are restricted
on the data types supported by the image format you are using, for example
MRCImageIO complains with scalar double types, while double type
works perfectly fine with MetaIO format.

> For example: itk::GradientMagnitudeImageFilter requires the input image
to have a float pixel type (as described in the software guide).
> Where can I find this kind of informations?

In the case of itk::GradientMagnitudeImageFilter you might want to have a
floating point pixel values, as you might want a continuous histogram, i.e.
you don't want to approximate real values to an integer type, as you loose
all the decimals. But itk::GradientMagnitudeImageFilter works perfectly
fine with integers too. Another example, if you want to threshold an image,
it's unnecessary to use a floating point pixel type, as usually you need to
store integer values, not decimals. But it works perfectly fine using
floating pixel types. It really depends on what is the problem you are
going to solve. Does it make sense?

cheers,
Mauro





2013/12/12 Mauro Maiorca <mauromaiorca at gmail.com>
>
>> Hi Elena,
>>
>> have a look at the ITK software guide (
>> http://www.itk.org/ItkSoftwareGuide.pdf), chapter 4 (User's guide ->
>> Data Representation -> Image), it might answer your question.
>>
>> Section 4.1.1 shows how to create a 3D image with unsigned short pixel
>> data, in summary you have to define your image type as:
>> typedef itk::Image< unsigned short, 3 > ImageType;
>> If you want to create an image with unsigned int pixel data, you have to
>> replace "unsigned short" with "unsigned int", i.e.
>> typedef itk::Image< unsigned int, 3 > ImageType;
>>
>> You can play with the examples that you can find either in your ITK
>> source directory (Examples/DataRepresentation/Image/Image1.cxx, etc etc) or
>> online (
>> https://github.com/Kitware/ITK/blob/master/Examples/DataRepresentation/Image/Image1.cxxetc etc)
>>
>> If you want to cast image types (for example converting from unsigned
>> short to unsigned int), have a look at section "6.3 Casting and Intensity
>> Mapping" of the ITK software guide.
>>
>> Hope it helps.
>>
>> cheers,
>> Mauro
>>
>>
>>
>>
>>
>> On Thu, Dec 12, 2013 at 8:19 PM, elena bresciani <
>> elena.bresciani87 at gmail.com> wrote:
>>
>>> Hi to everybody,
>>>
>>> I have a (probably really silly) question about which kind of input
>>> image pixel type does a filter require.
>>> Is it wrote in the doxygen documentation? If yes, where?
>>>
>>> I'm obviously a beginner and I can't understand well how to read the
>>> documentation...
>>>
>>> Thank you in advance,
>>>
>>> Elena
>>>
>>>
>>>
>>> _____________________________________
>>> 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/20131212/66fab849/attachment.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