<div dir="ltr">Hi Nirvedh,<div><br></div><div>For performance reasons, the iterators do not do bounds-checking.</div><div><br></div><div>HTH,</div><div>Matt</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 21, 2017 at 9:49 PM, Nirvedh Meshram <span dir="ltr"><<a href="mailto:nmeshram@wisc.edu" target="_blank">nmeshram@wisc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_-6282757756303712243divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" dir="ltr">
<p>Hello All,</p>
<p><br>
</p>
<p>I am working on a Code which is using an iterator which access pixels beyond the region boundary. However, this is not causing an error as I would expect it to. I need to use version 4.0 for legacy reasons. I am attaching a verifiable code and its output
with this issue. Let me know if this is a bug in my ITK version or I am missing something and this is correct behavior.</p>
<p><br>
</p>
<p></p>
<div>#include "itkImage.h"</div>
<div>#include "itkImageRegionIterator.h"</div>
<div>#include "itkVersion.h"</div>
<div>int main( int argc, char * argv[] )</div>
<div>{</div>
<div> typedef float InputPixelType;</div>
<div> typedef itk::Image< InputPixelType, 3 > InputImageType;</div>
<div><br>
</div>
<div> InputImageType::Pointer ip=InputImageType::New();</div>
<div> InputPixelType *input;</div>
<div> InputImageType::RegionType region,region1;</div>
<div> InputImageType::SizeType size,size1;</div>
<div> InputImageType::IndexType index,index1;</div>
<div> size[0]=5;</div>
<div> size[1]=5;</div>
<div> size[2]=5;</div>
<div> index[0]=0;</div>
<div> index[1]=0;</div>
<div> index[2]=0;</div>
<div><br>
</div>
<div> region.SetSize(size);</div>
<div> region.SetIndex(index);</div>
<div> std::cout<<region;</div>
<div> ip->SetRegions(region);</div>
<div> ip->Allocate();</div>
<div> size[2]=1;</div>
<div> region.SetSize(size);</div>
<div> std::cout<<region;</div>
<div> typedef itk::ImageRegionIterator<<wbr>InputImageType> Iteratortype;</div>
<div> Iteratortype It(ip,region);</div>
<div> int count=0;</div>
<div> for(It.GoToBegin();count<25*5;<wbr>count++,++It)</div>
<div> {</div>
<div> It.Set(27);</div>
<div> }</div>
<div> input=ip->GetBufferPointer();</div>
<div> for(int k=0;k<5;k++)</div>
<div> {</div>
<div> for(int i=0;i<5;i++)</div>
<div> {</div>
<div> for(int j=0;j<5;j++)</div>
<div> {</div>
<div> std::cout<<input[k*25+j+5*i]<<<wbr>" ";</div>
<div> }</div>
<div> std::cout<<"\n";</div>
<div><br>
</div>
<div> }</div>
<div> std::cout<<"\n";</div>
<div> }</div>
<div> itk::Version *Ver=itk::Version::New();</div>
<div> std::cout<<Ver-><wbr>GetITKMajorVersion()<<"."<<<wbr>Ver->GetITKMinorVersion()<<"\<wbr>n";</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> return EXIT_SUCCESS;</div>
<div>}</div>
<div><br>
</div>
Output:
<p></p>
<p><br>
</p>
<p></p>
<div>ImageRegion (0x7ffcfc489560)</div>
<div> Dimension: 3</div>
<div> Index: [0, 0, 0]</div>
<div> Size: [5, 5, 5]</div>
<div>ImageRegion (0x7ffcfc489560)</div>
<div> Dimension: 3</div>
<div> Index: [0, 0, 0]</div>
<div> Size: [5, 5, 1]</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div><br>
</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div><br>
</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div><br>
</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div><br>
</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div>27 27 27 27 27</div>
<div><br>
</div>
<div>4.0</div>
<div><br>
</div>
<br>
<p></p>
<p><br>
</p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/community</a><br>
<br></blockquote></div><br></div>