<div>Hello,</div>  <div>&nbsp;</div>  <div>I have image of short pixel type.&nbsp;I need to save the image into another file&nbsp;with pixels of certain intensity levels. The code is given below but unfortunately it is saving pixels with&nbsp;intensity levels other than desired. Any idea would appreciated.</div>  <div>&nbsp;</div>  <div>Thanks<BR>Shahab</div>  <div>&nbsp;</div>  <div>#include "itkImage.h"<BR>#include "itkImageFileReader.h"<BR>#include "itkImageFileWriter.h"<BR>#include &lt;iostream&gt;<BR>using namespace std;</div>  <div>&nbsp;</div>  <div>int main()<BR>{</div>  <div>int&nbsp;xdim = 256;</div>  <div>int ydim = 256;</div>  <div>int zdim = 128;</div>  <div><BR>&nbsp;typedef itk::Image&lt; short, 3 &gt; ImageType;<BR>&nbsp;ImageType::Pointer image = ImageType::New();</div>  <div>&nbsp;</div>  <div>&nbsp;typedef itk::ImageFileReader&lt; ImageType &gt; ReaderType;<BR>&nbsp;typedef itk::ImageFileWriter&lt; ImageType &gt; WriterType;</div>  <div>&nbsp;</div> 
 <div>&nbsp;ReaderType::Pointer reader = ReaderType::New();<BR>&nbsp;WriterType::Pointer writer = WriterType::New();</div>  <div>&nbsp;</div>  <div>&nbsp;reader-&gt;SetFileName( "seg2.img" );<BR>&nbsp;writer-&gt;SetFileName( "rhippo_seg.hdr" );</div>  <div>&nbsp;</div>  <div>&nbsp;image = reader-&gt;GetOutput();<BR>&nbsp;writer-&gt;SetInput( reader-&gt;GetOutput() );</div>  <div>&nbsp;</div>  <div>&nbsp;try&nbsp;<BR> { <BR>&nbsp;&nbsp;reader-&gt;Update();<BR>} <BR>&nbsp;&nbsp;<BR>&nbsp;catch( itk::ExceptionObject &amp; err )&nbsp;<BR> { <BR>&nbsp;&nbsp;cout &lt;&lt; "ExceptionObject caught !" &lt;&lt; endl; <BR>&nbsp;&nbsp;cout &lt;&lt; err &lt;&lt; endl; <BR>&nbsp;&nbsp;system("pause");<BR>&nbsp;&nbsp;return 1;<BR>}<BR>&nbsp;<BR>&nbsp;ImageType::PixelType pixelValue;<BR>&nbsp;ImageType::IndexType pixelIndex;</div>  <div>&nbsp;for(int z=0; z&lt;zdim; z++){<BR>&nbsp;&nbsp;for(int y=0; y&lt;ydim; y++){<BR>&nbsp;&nbsp;&nbsp;for(int x=0; x&lt;xdim; x++){</div> 
 <div>&nbsp;&nbsp;&nbsp;&nbsp;pixelIndex[0] = x; // x position<BR>&nbsp;&nbsp;&nbsp;&nbsp;pixelIndex[1] = y; // y position<BR>&nbsp;&nbsp;&nbsp;&nbsp;pixelIndex[2] = z; // z position</div>  <div>&nbsp;&nbsp;&nbsp;&nbsp;try <BR>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pixelValue = image-&gt;GetPixel( pixelIndex );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(pixelValue == 53) //need in&nbsp;this intensity&nbsp;value and hoping binary output image<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image-&gt;SetPixel( pixelIndex, 32767 );<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image-&gt;SetPixel( pixelIndex,&nbsp;-32766 );<BR>&nbsp;&nbsp;&nbsp;&nbsp;} <BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;catch( itk::ExceptionObject &amp; err ) <BR>&nbsp;&nbsp;&nbsp;&nbsp;{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout &lt;&lt; "ExceptionObject caught !" &lt;&lt; endl; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout &lt;&lt; err &lt;&lt; endl;
 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system("pause");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>&nbsp; <BR>&nbsp;try <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;writer-&gt;Update();<BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;&nbsp;<BR>&nbsp;catch( itk::ExceptionObject &amp; err ) <BR>&nbsp;&nbsp;&nbsp; { <BR>&nbsp;&nbsp;cout &lt;&lt; "ExceptionObject caught !" &lt;&lt; endl; <BR>&nbsp;&nbsp;cout &lt;&lt; err &lt;&lt; endl; <BR>&nbsp;&nbsp;system("pause");<BR>&nbsp;&nbsp;return 1;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; <BR>&nbsp;system("pause");<BR>&nbsp;return 0;<BR>}</div><p>
                <hr size=1>Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. <a href="http://us.rd.yahoo.com/mail_us/taglines/postman7/*http://us.rd.yahoo.com/evt=39666/*http://beta.messenger.yahoo.com"> Great rates starting at 1&cent;/min.