ITK users,<br><br>I'm still somewhat new to ITK.&nbsp; I'm trying to figure out how Image regions control where iterators may 'roam'.&nbsp; My problem may lie in that I don't fully understand how the BufferedRegion, LargestPossibleRegion, and regular Region differ.&nbsp; An example that I am trying to extend is Example/Iterators/ImageRegionIterator.cxx.&nbsp; I want to output an image that is the same overall size/spacing as the input image.&nbsp; I am trying to process a region in the input image (say squaring the pixel values) and output the pixel values in the output image in the same pixel index.
<br><br>So far I've only processed a region of the input image and can only get two outcomes to work.<br>1.) The output image is the same LargestPossibleRegion but the copied pixel values lie outside of the region that was processed in the input image.
<br>2.) Essentially the output of what /Examples/Iterators/ImageRegionIterator.cxx would give... an output image with LargestPossibleRegion = Input image processsed region with accuratly placed pixel values.<br><br>Is there something that I am overlooking to force the output Iterator to only operate on the corresponding processed subregion within the output image?&nbsp; I tried setting the output image SetBufferedRegion(input process image region size) and SetLargestPossibleRegion(sourceImage-&gt;GetLargestPossibleRegion()) but it didn't work.&nbsp; I will include the portion of code that I am trying to describe in case anything is unclear above.
<br><br>&nbsp;&nbsp;&nbsp; ImageType::ConstPointer sourceImage = reader-&gt;GetOutput();<br>&nbsp;&nbsp;&nbsp; ImageType::RegionType maxSourceRegion = sourceImage-&gt;GetLargestPossibleRegion();<br>&nbsp;&nbsp;&nbsp; ImageType::SizeType maxSourceRegionSize = maxSourceRegion.GetSize
();<br>&nbsp;&nbsp;&nbsp; ImageType::IndexType maxSourceRegionIndex = maxSourceRegion.GetIndex();<br><br>&nbsp;&nbsp;&nbsp; WriterType::Pointer writer = WriterType::New();<br>&nbsp;&nbsp;&nbsp; writer-&gt;SetFileName(argv[2]);<br><br>&nbsp;&nbsp;&nbsp; ImageType::RegionType sourceInputRegion;
<br>&nbsp;&nbsp;&nbsp; ImageType::RegionType::IndexType sourceRegionStartIndex;<br>&nbsp;&nbsp;&nbsp; ImageType::RegionType::SizeType sourceRegionStartSize;<br><br>&nbsp;&nbsp;&nbsp; sourceRegionStartIndex[0] = ::atoi(argv[3]);<br>&nbsp;&nbsp;&nbsp; sourceRegionStartIndex[1] = ::atoi(argv[4]);
<br><br>&nbsp;&nbsp;&nbsp; sourceRegionStartSize[0] = ::atoi(argv[5]);<br>&nbsp;&nbsp;&nbsp; sourceRegionStartSize[1] = ::atoi(argv[6]);<br><br>&nbsp;&nbsp;&nbsp; sourceInputRegion.SetSize(sourceRegionStartSize);<br>&nbsp;&nbsp;&nbsp; sourceInputRegion.SetIndex(sourceRegionStartIndex);
<br><br>&nbsp;&nbsp;&nbsp; ImageType::RegionType outputRegion;<br>&nbsp;&nbsp;&nbsp; ImageType::RegionType::IndexType outputRegionStartIndex;<br>&nbsp;&nbsp;&nbsp; ImageType::RegionType::SizeType outputRegionStartSize;<br><br>&nbsp;&nbsp;&nbsp; outputRegionStartIndex[0] = ::atoi(argv[3]);
<br>&nbsp;&nbsp;&nbsp; outputRegionStartIndex[1] = ::atoi(argv[4]);<br><br>&nbsp;&nbsp;&nbsp; outputRegionStartSize[0] = ::atoi(argv[5]);<br>&nbsp;&nbsp;&nbsp; outputRegionStartSize[1] = ::atoi(argv[6]);<br><br>&nbsp;&nbsp;&nbsp; outputRegion.SetSize(outputRegionStartSize);<br>&nbsp;&nbsp;&nbsp; 
outputRegion.SetIndex(outputRegionStartIndex);<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ImageType::Pointer outputImage = ImageType::New();<br>&nbsp;&nbsp;&nbsp; outputImage-&gt;SetRegions(outputRegion);<br>&nbsp;&nbsp;&nbsp; const ImageType::SpacingType &amp; spacing =<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;GetOutput()-&gt;GetSpacing();
<br>&nbsp;&nbsp;&nbsp; const ImageType::PointType &amp; inputOrigin =<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; reader-&gt;GetOutput()-&gt;GetOrigin();<br>&nbsp;&nbsp;&nbsp; double outputOrigin[Dimension];<br><br>&nbsp;&nbsp;&nbsp; for(unsigned int i=0; i&lt;Dimension; i++) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; outputOrigin[i] = inputOrigin[i]+spacing[i]*sourceRegionStartIndex[i];<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; outputImage-&gt;SetSpacing(spacing);<br>&nbsp;&nbsp;&nbsp; outputImage-&gt;SetOrigin(outputOrigin);<br>&nbsp;&nbsp;&nbsp; //outputImage-&gt;SetLargestPossibleRegion(sourceImage-&gt;GetLargestPossibleRegion());
<br>&nbsp;&nbsp;&nbsp; outputImage-&gt;Allocate();<br><br>&nbsp;&nbsp;&nbsp; ConstIteratorType inputIt(reader-&gt;GetOutput(),sourceInputRegion);<br>&nbsp;&nbsp;&nbsp; IteratorType outputIt(outputImage,outputRegion);<br><br><br>(process pixel values in regions and send to same index in output image)
<br>(update writer)<br><br><br>Many thanks in advance ~<br><br>Jared<br>