Looks like a case of the copy/paste bug:<div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">&quot;for(unsigned int k = 0; j &lt; size_z; j++)&quot;</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">P.S. Use an image iterator :)<br>
</span></font><br><div class="gmail_quote">On Wed, Jun 15, 2011 at 6:20 PM, 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 to all,<br><br>I am trying to do a simple task.Well, I am trying to create a 3D image.Fill all the vosels with value 255 and then get the max value (just to see if my program works fine).But every time it is running I get an exception which has to do with the area allocated in the memory.What am I doing wrong. ihope that someone could help me<br>

<br>Thanks<br><br>  InputImageType::Pointer image_norm;<br><br>  InputImageType::IndexType start;<br>  start.Fill(0);<br> <br>  InputImageType::SizeType size;<br>  size[0]=size_x;<br>  size[1]=size_y;<br>  size[2]=size_z;<br>

<br> <br>  InputImageType::RegionType region(start, size);<br>  image_norm-&gt;SetRegions(region);<br>  image_norm-&gt;Allocate();<br>  image_norm-&gt;FillBuffer(255);<br><br>  int max=0;<br>     for(unsigned int i = 0; i &lt; size_x; i++)<br>

      {<br>      for(unsigned int j = 0; j &lt; size_y; j++)<br>                {<br>        for(unsigned int k = 0; j &lt; size_z; j++)<br>                        {<br>                                InputImageType::IndexType pixelIndex;<br>

                                pixelIndex[0] = i;<br>                                pixelIndex[1] = j;<br>                                pixelIndex[2] = k;<br>  <br>                            int value= image_norm-&gt;GetPixel(pixelIndex);<br>

                            if (value&gt;max){max=value;}<br>                        }<br><br>                }<br>      }<br>ui-&gt;label_61-&gt;setText(QString(&quot;max:%1&quot;).arg( max ));<br><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">

</div>
<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></div>