<div>Most of your questions are clearly addressed in the ITK Software guide:</div><div><br></div><div><a href="http://www.itk.org/ItkSoftwareGuide.pdf">www.itk.org/ItkSoftwareGuide.pdf</a></div><div><br></div><div>See Ch.7: Reading and Writing Images</div>
<div><br></div><div class="gmail_quote">On Tue, Jun 7, 2011 at 11:36 AM, john smith <span dir="ltr">&lt;<a href="mailto:mkitkinsightuser@gmail.com">mkitkinsightuser@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br><br>Now I have used iterators in order to normalize an image, which I load  from a file using a reader. I have created an <i>out </i>iterator in order to set the new values of my image. I want to ask how could I write the image with the changed values into a .png file?<br>

<br>Thanks in advance for your help.<br><br>typedef itk::ImageRegionIterator&lt;InputImageType&gt; ImageIteratorType;<br>typedef InputImageType::RegionType               RegionType;<br>typedef InputImageType::PixelType                PixelType;<br>

<br> ReaderType::Pointer reader = ReaderType::New();<br>     reader-&gt;SetFileName( fileName.toStdString()  );<br>     reader-&gt;Update();<br><br>      InputImageType::RegionType inputRegion =<br>           reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br>

<br> InputImageType::Pointer image = reader-&gt;GetOutput();<br><br>// Get image region<br>RegionType region = image-&gt;GetLargestPossibleRegion();<br><br>// Create iterator<br>ImageIteratorType it( image, region );<br>
it.GoToBegin();<br>
<br>ImageIteratorType out( image, region );<br>out.GoToBegin();<br><br>// Initialization of max_value<br>int max_value=0;<br>int min_value=0;<br><br>// Loop<br>while(!it.IsAtEnd())<br>{<br> // Pixel value<br> PixelType pixel = it.Get();<br>

 <br> // Is it bigger than the max?<br> if (pixel&gt;max_value)<br>   max_value = pixel;<br><br>  if (pixel&lt;min_value)<br>   min_value = pixel;<br> // Increment iterator<br> ++it;<br>}<br> ui-&gt;label_22-&gt;setText(QString(&quot;maximum_value_raw:%1&quot;).arg(max_value));<br>

 ui-&gt;label_23-&gt;setText(QString(&quot;minimum_value_raw:%1&quot;).arg(min_value));<br><br>// Loop<br>if (max_value&gt;255){<br>        while(!it.IsAtEnd())<br>        {<br>         // Pixel value<br>         PixelType pixel = it.Get();<br>

 <br>         // Is it bigger than the max?<br>         out.Set(255*((pixel-min_value)/(max_value-min_value)));<br>         // Increment iterator<br>         ++it;<br>         ++out;<br>        }<br>}<br>
<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.html" target="_blank">http://www.kitware.com/products/protraining.html</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>
<br></blockquote></div><br>