[Insight-users] difference between get and getPixel

Matt McCormick matt.mccormick at kitware.com
Sun Aug 4 23:36:31 EDT 2013


Hi pengpeng,

The first cast to unsigned char is overflowing - 179 = 435 -  256.

Hth,
Matt
On Aug 4, 2013 10:17 PM, "pengpeng" <helloliupengxin at gmail.com> wrote:

> Dear ITK Friend
>
> I want to get any position pixel value of 3D DICOM volume.
> But when I use iterator.get and getpixel, the results are different.
> The first one reads 179 while the second reads 435. Can anyone help?
> Thanks a lot.
>
> < iterator code >
>               InternalImageType::Pointer imageForI =reader->GetOutput();
>               InternalImageType::SizeType regionSize;
>               regionSize[0]=1;
>               regionSize[1]=1;
>               regionSize[2]=1;
>
>               InternalImageType::IndexType regionIndex;
>               regionIndex[0]=128;
>               regionIndex[1]=128;
>               regionIndex[2]=2;
>
>               InternalImageType::RegionType region;
>               region.SetSize(regionSize);
>               region.SetIndex(regionIndex);
>
>               itk::ImageRegionConstIterator<InternalImageType>
> imageIterator(imageForI,region);
>               while(!imageIterator.IsAtEnd())
>                 {
>                 unsigned char val = imageIterator.Get();
>                 std::cout <<" Pixel is "<< (int)val << std::endl;
>                 ++imageIterator;
>                 }
> < end iterator code >
> <getpixel code>
>              InternalImageType::IndexType pi={128,128,2};
>              std::cout<<"pixel is
> "<<reader->GetOutput()->GetPixel(pi)<<std::endl;
> &lt;end getpixel code>
>
>
>
>
> --
> View this message in context:
> http://itk-users.7.n7.nabble.com/difference-between-get-and-getPixel-tp32048.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130804/e06d7b4c/attachment.htm>


More information about the Insight-users mailing list