<p dir="ltr">Hi pengpeng, </p>
<p dir="ltr">The first cast to unsigned char is overflowing - 179 = 435 - 256.</p>
<p dir="ltr">Hth,<br>
Matt </p>
<div class="gmail_quote">On Aug 4, 2013 10:17 PM, "pengpeng" <<a href="mailto:helloliupengxin@gmail.com">helloliupengxin@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear ITK Friend<br>
<br>
I want to get any position pixel value of 3D DICOM volume.<br>
But when I use iterator.get and getpixel, the results are different.<br>
The first one reads 179 while the second reads 435. Can anyone help?<br>
Thanks a lot.<br>
<br>
< iterator code ><br>
InternalImageType::Pointer imageForI =reader->GetOutput();<br>
InternalImageType::SizeType regionSize;<br>
regionSize[0]=1;<br>
regionSize[1]=1;<br>
regionSize[2]=1;<br>
<br>
InternalImageType::IndexType regionIndex;<br>
regionIndex[0]=128;<br>
regionIndex[1]=128;<br>
regionIndex[2]=2;<br>
<br>
InternalImageType::RegionType region;<br>
region.SetSize(regionSize);<br>
region.SetIndex(regionIndex);<br>
<br>
itk::ImageRegionConstIterator<InternalImageType><br>
imageIterator(imageForI,region);<br>
while(!imageIterator.IsAtEnd())<br>
{<br>
unsigned char val = imageIterator.Get();<br>
std::cout <<" Pixel is "<< (int)val << std::endl;<br>
++imageIterator;<br>
}<br>
< end iterator code ><br>
<getpixel code><br>
InternalImageType::IndexType pi={128,128,2};<br>
std::cout<<"pixel is<br>
"<<reader->GetOutput()->GetPixel(pi)<<std::endl;<br>
&lt;end getpixel code><br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-users.7.n7.nabble.com/difference-between-get-and-getPixel-tp32048.html" target="_blank">http://itk-users.7.n7.nabble.com/difference-between-get-and-getPixel-tp32048.html</a><br>
Sent from the ITK - Users mailing list archive at Nabble.com.<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div>