[ITK-users] Numeric traits

Jim Miller millerjv at gmail.com
Fri Oct 24 07:31:24 EDT 2014


This statement assigns the value of 1 to variable "label".  The value of
NumericTraits<PixelType>::One is specific to the datatype PixelType.  For
instance, For an integer type, NumericTraits<PixelType>::One will be 1. For
a floating point type, it will be 1.0.

Techniques like this are used in Generic Programming to initialize or
assign a variable a value of the appropriate type (and avoid compiler
warnings and performance associated with casting between types).


On Fri, Oct 24, 2014 at 4:32 AM, Abdul Abdul <abdul.sw84 at gmail.com> wrote:

> Hello,
>
> I came across the following statement:
>
> PixelType label = itk::NumericTraits<PixelType>::One;
>
> It seems to be related to numric traits, which I have visited its
> documentation website, here
> <http://www.itk.org/Doxygen/html/classitk_1_1NumericTraits.html>, but,
> yet, didn't get the idea of the statement.
>
> Can you kindly just describe to me what the statement means?
>
> Thanks.
>
>
> _____________________________________
> 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://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20141024/d0ad3f80/attachment-0001.html>


More information about the Insight-users mailing list