[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>&nbsp;</DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>Currently, the 
ExtractRegion is based on the output image region type.&nbsp; 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.&nbsp; 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.&nbsp; </FONT></SPAN></DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff 
size=2></FONT></SPAN>&nbsp;</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>&nbsp;</DIV>
<DIV><SPAN class=185422117-21032002><FONT color=#0000ff size=2>One idea would be 
along your method.&nbsp; 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>&nbsp;</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>&nbsp;</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>&nbsp;</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&nbsp;change in dimensions.&nbsp; Does it 
  seem reasonable to add this functionality&nbsp;to reduce dimensions to 
  ExtractImageFilter?</FONT></DIV>
  <DIV><FONT face=Arial size=2>As an API, does calling&nbsp;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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; //</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; //Lets go from 4-D to 
  3-D</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; //get the (x,y,z,6) 
  slice.&nbsp; This might correspond to the 7th time slice </FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; //in a time-series 
  of&nbsp;</FONT><FONT face=Arial size=2>3-D images</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; //</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
  ExtractImageFilter&lt;4DimImage, 3DimImage&gt;&nbsp;extractor;</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
  extractor-&gt;SetInput(4DImage-&gt;GetOutput());<BR>&nbsp;&nbsp;&nbsp; 
  extractorIndex = {0,0,0,6};<BR>&nbsp;&nbsp;&nbsp; extractorSize = 
  {4DImageSize[0], 4DImageSize[1], 4DImageSize[2], 0};<BR>&nbsp;&nbsp;&nbsp; 
  extractorRegion.SetSize(extractorSize);<BR>&nbsp;&nbsp;&nbsp; 
  extractorRegion.SetIndex(extractorIndex);<BR>&nbsp;&nbsp;&nbsp; 
  extractor-&gt;SetExtractionRegion(extractorRegion);</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</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.&nbsp; </FONT><FONT face=Arial size=2>or is there a better 
  way to do this?&nbsp; 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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>if&nbsp;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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>thoughts?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>wilson</DIV>
  <DIV><BR></DIV></FONT>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV><PRE><FONT face=Arial size=2>&gt;You might want to look at the ExtractImageFilter.  I don't
&gt;know whether it will allow you to have an output image whose dimension is less
&gt;than the input's.  But that is where I would look for such functionality
&gt;</FONT><FONT face=Arial size=2>&gt;
&gt;&gt;-----Original Message-----
&gt;&gt;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>]
&gt;&gt;Sent: Tuesday, March 12, 2002 2:49 PM
&gt;&gt;To: Insight Developers
&gt;&gt;Subject: [Insight-developers] dimension reduction / VTK link&gt;&gt;
&gt;&gt;
&gt;&gt;Hi,
&gt;&gt;
&gt;&gt;We're working on a tool for visualizing ITK images (in the context of our 
&gt;&gt;core atom project) and we've run into the following situation:
&gt;&gt;
&gt;&gt;VTK looks attractive, but can only handle 3D images. Is there an easy way 
&gt;&gt;(in ITK) to "lock" N-3 dimensions of an N-d dataset, and get the 3D subset 
&gt;&gt;this defines? E.g., I have a 4D "movie", I want to hold time constant and 
&gt;&gt;extract a 3D "frame".
&gt;&gt;
&gt;&gt;itkVTKImageExport.h doesn't suggest how this should be done, but it seems 
&gt;&gt;like a fairly straightforward problem (interpolation issues aside). The 
&gt;&gt;naive way of doing it would be to compute the indices of interest for the 
&gt;&gt;"locked" dimensions, and then build an output image by looping over the &gt;
&gt;&gt;free variables, but this isn't particularly elegant, and for large subsets 
&gt;&gt;could involve a lot of copying.
&gt;&gt;
&gt;&gt;Alternatively, is it possible to use an ImageRegionIterator to accomplish 
&gt;&gt;this, by selecting origin=(0,0,0,timeindex) and size=(xsize,ysize,zsize,1)? 
&gt;&gt;If so, is there an established method (a filter perhaps) for creating an 
&gt;&gt;image given a source image and an iterator?
&gt;&gt;
&gt;&gt;Also, is the interpretation of the image by itkVTKImageExport affected by 
&gt;&gt;the currently requested/buffered region definition?
&gt;&gt;
&gt;&gt;In a separate but related question, is it possible in ITK to obtain 
&gt;&gt;arbitrary 2D slices through a 3D volume by defining the equation of a 
&gt;&gt;cutting plane, as can be done in VTK?
&gt;&gt;
&gt;&gt;Thanks,
&gt;&gt;-Damion-</FONT></PRE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C1D0FE.D1845562--