[Insight-users] Pixel value

Luis Ibanez luis.ibanez at kitware.com
Tue Feb 10 17:18:27 EST 2009


Hi Camilo,

If you need to convert the pixel value to another type
you can simply use static_cast< type >( pixelValue ).

Note however, that the C-language casting rules will apply.

For example, if the PixelType is actually  float and
you cast it to int, then you will lose information from
the pixel value, like in


    int value = static_cast< int >( myIterator.Get() );


It is your responsibility to make sure that the recipient
type (the int or the double) are capable of storing the
input value without loss of precision.


Regards,


     Luis



-----------------
Camilo Diaz wrote:
> Hello List:
> 
> I was wondering how can i get the pixel's value.
> I mean, the iterator in the .Get method returns a PixelType, but what if 
> i need the int or double value?
> 
> 
> i'll appreciate the help
> 
> Camilo
> 
> -- 
> Kmilo
> 
> 
> ------------------------------------------------------------------------
> 
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> 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 Insight-users mailing list