[Insight-users] GetPixel() strange behavior

Dominique Töpfer dominique at toepfer-web.de
Wed Jun 19 07:52:30 EDT 2013


Hi,

I think GetPixel returns the value exactly as stored in memory, but 
std::cout interprets char's as ASCII. Try casting your variable to int. 
This worked for me:

   char c = 68;
   std::cout << c << std::endl;
   std::cout << static_cast<int>(c) << std::endl;

The first cout prints a 'D', the second one 68 as expected.

HTH
Dominique

Am 19.06.2013 13:08, schrieb Antonio Calabrese:
> Hi Cheung,
> talking with a friend, we thought that GetPixel method, it used as cost
> version, take the value as it stored in memory.
> I don't think that the ASCII representation of one pixel is the result that
> GetPixel returns to me, because i tried also to define my image with a
> integer pixeltype, but the result was the same.
> Now i would to try with an iteration class that have a GetValue method. I
> hope to be able to solve it in this way.
> Hi Antonio
>
>
>
> --
> View this message in context: http://itk-users.7.n7.nabble.com/GetPixel-strange-behavior-tp31719p31729.html
> Sent from the ITK - Users mailing list archive at Nabble.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



More information about the Insight-users mailing list