<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" 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<InputImageType> Iteratortype;</div>
<div> Iteratortype It(ip,region);</div>
<div> int count=0;</div>
<div> for(It.GoToBegin();count<25*5;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]<<" ";</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->GetITKMajorVersion()<<"."<<Ver->GetITKMinorVersion()<<"\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>
</body>
</html>