[Insight-developers] ExtractImageFilter and reducing dimensio
ns
Miller, James V (CRD)
millerjv@crd.ge.com
Thu, 21 Mar 2002 12:35:39 -0500
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C1D0FE.D1845562
Content-Type: text/plain;
charset="iso-8859-1"
ExtractImageFilter always creates an iterator and copies pixels to the output.
Currently, the ExtractRegion is based on the output image region type. This
type allows the ExtractImageFilter support both a reduction in dimension and not. So there
is no need to set a size of zero to specify a reduction in dimension since the output dimension
will already be the appropriate dimension.
However, what is missing is a mapping of what input dimensions to use for the extraction.
One idea would be along your method. Change the ExtractRegion to be based on the
input image region type and use zeros to indicate dimensions that are skipped. Then
"collapse" that region (removing any zeros) to define the region for the output image.
You would still use two iterators, one to walk the output and one to walk the input.
To support the reduction in dimension, the input iterator should probably be a
ImageSliceIteratorWithIndex so you can specify what directions to walk fastest.
This tricky part is that if you have a volume and want to extract an image that
is orthogonal to the slice plane (acquisition plane), then you may only iterate
X and Z (and not Y) or Y and Z (and not X). The standard RegionIterators would be
inefficient at that.
-----Original Message-----
From: Wilson Chang [mailto:wmcst6+@pitt.edu]
Sent: Thursday, March 21, 2002 12:01 PM
To: Insight Developers
Subject: [Insight-developers] ExtractImageFilter and reducing dimensions
It looks as if ExtractImageFilter doesn't allow a change in dimensions. Does it seem reasonable to
add this functionality to reduce dimensions to ExtractImageFilter?
As an API, does calling SetExtractionRegion with a size of 0 as one of the dimension to get rid of
that particular dimension seem reasonable (example below)?:
//
//Lets go from 4-D to 3-D
//get the (x,y,z,6) slice. This might correspond to the 7th time slice
//in a time-series of 3-D images
//
ExtractImageFilter<4DimImage, 3DimImage> extractor;
extractor->SetInput(4DImage->GetOutput());
extractorIndex = {0,0,0,6};
extractorSize = {4DImageSize[0], 4DImageSize[1], 4DImageSize[2], 0};
extractorRegion.SetSize(extractorSize);
extractorRegion.SetIndex(extractorIndex);
extractor->SetExtractionRegion(extractorRegion);
Implementation in ExtractImageFilter would probably entail using an iterator to walk through the
desired dimensions and copy out the data. or is there a better way to do this? As far as I cant
tell, adding this functionality wont result in a performance hit over the existing code if we make a
dimension reduction a special case in the code:
if nDimensions to nDimension extraction then use existing code
else if nDimension to (n-m)Dimension, then use an iterator to walk through data and copy out data.
thoughts?
wilson
>You might want to look at the ExtractImageFilter. I don't
>know whether it will allow you to have an output image whose dimension is less
>than the input's. But that is where I would look for such functionality
>>
>>-----Original Message-----
>>From: Damion Shelton [mailto: <mailto:dmshelto@andrew.cmu.edu> dmshelto@andrew.cmu.edu]
>>Sent: Tuesday, March 12, 2002 2:49 PM
>>To: Insight Developers
>>Subject: [Insight-developers] dimension reduction / VTK link>>
>>
>>Hi,
>>
>>We're working on a tool for visualizing ITK images (in the context of our
>>core atom project) and we've run into the following situation:
>>
>>VTK looks attractive, but can only handle 3D images. Is there an easy way
>>(in ITK) to "lock" N-3 dimensions of an N-d dataset, and get the 3D subset
>>this defines? E.g., I have a 4D "movie", I want to hold time constant and
>>extract a 3D "frame".
>>
>>itkVTKImageExport.h doesn't suggest how this should be done, but it seems
>>like a fairly straightforward problem (interpolation issues aside). The
>>naive way of doing it would be to compute the indices of interest for the
>>"locked" dimensions, and then build an output image by looping over the >
>>free variables, but this isn't particularly elegant, and for large subsets
>>could involve a lot of copying.
>>
>>Alternatively, is it possible to use an ImageRegionIterator to accomplish
>>this, by selecting origin=(0,0,0,timeindex) and size=(xsize,ysize,zsize,1)?
>>If so, is there an established method (a filter perhaps) for creating an
>>image given a source image and an iterator?
>>
>>Also, is the interpretation of the image by itkVTKImageExport affected by
>>the currently requested/buffered region definition?
>>
>>In a separate but related question, is it possible in ITK to obtain
>>arbitrary 2D slices through a 3D volume by defining the equation of a
>>cutting plane, as can be done in VTK?
>>
>>Thanks,
>>-Damion-
------_=_NextPart_001_01C1D0FE.D1845562
Content-Type: text/html;
charset="iso-8859-1"
<!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 5.50.4807.2300" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2>ExtractImageFilter always creates an iterator and copies pixels to the
output.</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>Currently, the
ExtractRegion is based on the output image region type. This
</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>type allows the
ExtractImageFilter support both a reduction in dimension and not. So
there</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>is no need to set
a size </FONT></SPAN><SPAN class=185422117-21032002><FONT color=#0000ff
size=2>of zero to specify a reduction in dimension since the output dimension
</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>will already be
the appropriate </FONT></SPAN><SPAN class=185422117-21032002><FONT color=#0000ff
size=2>dimension. </FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>However, what is
missing is a mapping of what input dimensions to use for the
extraction.</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>One idea would be
along your method. Change the ExtractRegion to be based on the
</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>input image
region type and use zeros to indicate dimensions that are skipped.
Then</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>"collapse" that
region (removing any zeros) to define the region for the output
image.</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>You would still
use two iterators, one to walk the output and one to walk the
input.</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>To support the
reduction in dimension, the input iterator should probably be a
</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2>ImageSliceIteratorWithIndex so you can specify what directions to walk
fastest.</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>This tricky part
is that if you have a volume and want to extract an image
that</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>is orthogonal to
the slice plane (acquisition plane), then you may only iterate
</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>X and Z (and not
Y) or Y and Z (and not X). The standard RegionIterators would
be</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>inefficient at
that.</FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Wilson Chang
[mailto:wmcst6+@pitt.edu]<BR><B>Sent:</B> Thursday, March 21, 2002 12:01
PM<BR><B>To:</B> Insight Developers<BR><B>Subject:</B> [Insight-developers]
ExtractImageFilter and reducing dimensions<BR><BR></FONT></DIV>
<DIV><!--StartFragment --><FONT face=Arial size=2>It looks as if
ExtractImageFilter doesn't allow a change in dimensions. Does it
seem reasonable to add this functionality to reduce dimensions to
ExtractImageFilter?</FONT></DIV>
<DIV><FONT face=Arial size=2>As an API, does calling SetExtractionRegion
with a size of 0 as one of the dimension to get rid of that particular
dimension seem reasonable (example below)?:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> //</FONT></DIV>
<DIV><FONT face=Arial size=2> //Lets go from 4-D to
3-D</FONT></DIV>
<DIV><FONT face=Arial size=2> //get the (x,y,z,6)
slice. This might correspond to the 7th time slice </FONT></DIV>
<DIV><FONT face=Arial size=2> //in a time-series
of </FONT><FONT face=Arial size=2>3-D images</FONT></DIV>
<DIV><FONT face=Arial size=2> //</FONT></DIV>
<DIV><FONT face=Arial size=2>
ExtractImageFilter<4DimImage, 3DimImage> extractor;</FONT></DIV>
<DIV><FONT face=Arial size=2>
extractor->SetInput(4DImage->GetOutput());<BR>
extractorIndex = {0,0,0,6};<BR> extractorSize =
{4DImageSize[0], 4DImageSize[1], 4DImageSize[2], 0};<BR>
extractorRegion.SetSize(extractorSize);<BR>
extractorRegion.SetIndex(extractorIndex);<BR>
extractor->SetExtractionRegion(extractorRegion);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Implementation in ExtractImageFilter would
probably entail using an iterator to walk through the desired dimensions and
copy out the data. </FONT><FONT face=Arial size=2>or is there a better
way to do this? As far as I cant tell, adding this functionality wont
result in a performance hit over the existing code if we make a dimension
reduction a special case in the code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>if nDimensions to nDimension extraction then
use existing code</FONT></DIV>
<DIV><FONT face=Arial size=2>else if nDimension to (n-m)Dimension, then use an
iterator to walk through data and copy out data.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>thoughts?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>wilson</DIV>
<DIV><BR></DIV></FONT>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><PRE><FONT face=Arial size=2>>You might want to look at the ExtractImageFilter. I don't
>know whether it will allow you to have an output image whose dimension is less
>than the input's. But that is where I would look for such functionality
></FONT><FONT face=Arial size=2>>
>>-----Original Message-----
>>From: Damion Shelton [mailto:</FONT><A href="mailto:dmshelto@andrew.cmu.edu"><FONT face=Arial size=2>dmshelto@andrew.cmu.edu</FONT></A><FONT face=Arial size=2>]
>>Sent: Tuesday, March 12, 2002 2:49 PM
>>To: Insight Developers
>>Subject: [Insight-developers] dimension reduction / VTK link>>
>>
>>Hi,
>>
>>We're working on a tool for visualizing ITK images (in the context of our
>>core atom project) and we've run into the following situation:
>>
>>VTK looks attractive, but can only handle 3D images. Is there an easy way
>>(in ITK) to "lock" N-3 dimensions of an N-d dataset, and get the 3D subset
>>this defines? E.g., I have a 4D "movie", I want to hold time constant and
>>extract a 3D "frame".
>>
>>itkVTKImageExport.h doesn't suggest how this should be done, but it seems
>>like a fairly straightforward problem (interpolation issues aside). The
>>naive way of doing it would be to compute the indices of interest for the
>>"locked" dimensions, and then build an output image by looping over the >
>>free variables, but this isn't particularly elegant, and for large subsets
>>could involve a lot of copying.
>>
>>Alternatively, is it possible to use an ImageRegionIterator to accomplish
>>this, by selecting origin=(0,0,0,timeindex) and size=(xsize,ysize,zsize,1)?
>>If so, is there an established method (a filter perhaps) for creating an
>>image given a source image and an iterator?
>>
>>Also, is the interpretation of the image by itkVTKImageExport affected by
>>the currently requested/buffered region definition?
>>
>>In a separate but related question, is it possible in ITK to obtain
>>arbitrary 2D slices through a 3D volume by defining the equation of a
>>cutting plane, as can be done in VTK?
>>
>>Thanks,
>>-Damion-</FONT></PRE></BLOCKQUOTE></BODY></HTML>
------_=_NextPart_001_01C1D0FE.D1845562--