<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff size=2>At
first glance, the only issue I see is your calculation of the origin. In
ITK, the origin corresponds to the physical coordinate (mm or ft, etc.) of the
pixel at index [0, 0, ...]. Since your output region starts at a non-zero
index, you should not need to move the origin. So just copy the origin and
spacing from the input image to the output image.</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff size=2>Can
you describe the "problem" in more detail? How does the output image
look?</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff size=2>There
could be a problem with the ImageFileWriter when the BufferedRegion does not
start at index [0,0,...]. You could place a RegionOfInterestImageFilter
before the ImageFileWriter (or an ChangeInformationImageFilter) to adjust the
image so that the BufferedRegion starts at [0,0,...]</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff size=2>Here
are the definitions of regions:</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2>RequestedRegion: How much of the image to process.</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2>BufferedRegion: How much of the image is in memory.</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2>LargestPossibleRegion: How big could the image be.
</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2>Filters are told to process a RequestedRegion. When a filter runs,
the RequestedRegion must be a subset of the BufferedRegion. The
LargestPossibleRegion is typically used to tell whether a pixel is a true
boundary condition or just a voxel at the edge of
BufferedRegion.</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2>Jim</FONT></SPAN></DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=420572713-12052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
insight-users-bounces+millerjv=crd.ge.com@itk.org
[mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of
</B>Jared Hoover<BR><B>Sent:</B> Thursday, May 11, 2006 8:33 PM<BR><B>To:</B>
insight-users@itk.org<BR><B>Subject:</B> [Insight-users] Using regions to
control iterators...<BR><BR></FONT></DIV>ITK users,<BR><BR>I'm still somewhat
new to ITK. I'm trying to figure out how Image regions control where
iterators may 'roam'. My problem may lie in that I don't fully
understand how the BufferedRegion, LargestPossibleRegion, and regular Region
differ. An example that I am trying to extend is
Example/Iterators/ImageRegionIterator.cxx. I want to output an image
that is the same overall size/spacing as the input image. 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? I tried setting the output image
SetBufferedRegion(input process image region size) and
SetLargestPossibleRegion(sourceImage->GetLargestPossibleRegion()) but it
didn't work. I will include the portion of code that I am trying to
describe in case anything is unclear above. <BR><BR>
ImageType::ConstPointer sourceImage =
reader->GetOutput();<BR> ImageType::RegionType
maxSourceRegion =
sourceImage->GetLargestPossibleRegion();<BR>
ImageType::SizeType maxSourceRegionSize = maxSourceRegion.GetSize
();<BR> ImageType::IndexType maxSourceRegionIndex =
maxSourceRegion.GetIndex();<BR><BR> WriterType::Pointer
writer = WriterType::New();<BR>
writer->SetFileName(argv[2]);<BR><BR>
ImageType::RegionType sourceInputRegion; <BR>
ImageType::RegionType::IndexType sourceRegionStartIndex;<BR>
ImageType::RegionType::SizeType
sourceRegionStartSize;<BR><BR> sourceRegionStartIndex[0] =
::atoi(argv[3]);<BR> sourceRegionStartIndex[1] =
::atoi(argv[4]); <BR><BR> sourceRegionStartSize[0] =
::atoi(argv[5]);<BR> sourceRegionStartSize[1] =
::atoi(argv[6]);<BR><BR>
sourceInputRegion.SetSize(sourceRegionStartSize);<BR>
sourceInputRegion.SetIndex(sourceRegionStartIndex); <BR><BR>
ImageType::RegionType outputRegion;<BR>
ImageType::RegionType::IndexType outputRegionStartIndex;<BR>
ImageType::RegionType::SizeType
outputRegionStartSize;<BR><BR> outputRegionStartIndex[0] =
::atoi(argv[3]); <BR> outputRegionStartIndex[1] =
::atoi(argv[4]);<BR><BR> outputRegionStartSize[0] =
::atoi(argv[5]);<BR> outputRegionStartSize[1] =
::atoi(argv[6]);<BR><BR>
outputRegion.SetSize(outputRegionStartSize);<BR>
outputRegion.SetIndex(outputRegionStartIndex);<BR>
<BR> ImageType::Pointer outputImage =
ImageType::New();<BR>
outputImage->SetRegions(outputRegion);<BR> const
ImageType::SpacingType & spacing =<BR>
reader->GetOutput()->GetSpacing();
<BR> const ImageType::PointType & inputOrigin
=<BR>
reader->GetOutput()->GetOrigin();<BR> double
outputOrigin[Dimension];<BR><BR> for(unsigned int i=0;
i<Dimension; i++) {<BR>
outputOrigin[i] =
inputOrigin[i]+spacing[i]*sourceRegionStartIndex[i];<BR>
}<BR><BR>
outputImage->SetSpacing(spacing);<BR>
outputImage->SetOrigin(outputOrigin);<BR>
//outputImage->SetLargestPossibleRegion(sourceImage->GetLargestPossibleRegion());
<BR> outputImage->Allocate();<BR><BR>
ConstIteratorType
inputIt(reader->GetOutput(),sourceInputRegion);<BR>
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></BLOCKQUOTE></BODY></HTML>