[Insight-users] Extract Image Filter

Puja Malik puja.malik@MEMcenter.unibe.ch
Tue, 04 Feb 2003 17:27:13 +0100


--Boundary_(ID_M3zbmFHbwSZ2QnIBPBdFRQ)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT

Hi Luis,

I've managed to fix my problem in the ExtractImageFilter.  I do have one
concern though.  I cannot directly use the image object from the output
of the filter, and view it in the fltk image filter.  If I do this, the
images intensity range is altered, and the first slice is distorted.
I must first write the output of the filter ( image object ) to a file,
read it back into a new image object and then view it.  This way, I see
a correctly extracted image.  This is very strange.  It would be
convenient if the output of the filter could be used directly.  Please
see my code below, including the extra steps I needed to perform to get
the desired results.

void ExtractImageRegion(ImageType::Pointer imIN, ImageType::SizeType
regSize,
                                                   ImageType::IndexType
regIndex)
{

 typedef itk::ExtractImageFilter< ImageType, ImageType > FilterType;
 FilterType::Pointer filter = FilterType::New();
 ImageType::Pointer imOUT;

 ImageType::RegionType region;
 region.SetSize(regSize);
 region.SetIndex(regIndex);

 filter->SetExtractionRegion(region);
 filter->SetInput(imIN);
 filter->Update();

// View(filter->GetOutput(), "region");  <-- doing this directly shows a
distorted image

//the following is the extra steps needed to view a correct image
//View, Read, WriteMetaFile are my own functions written using itk
classes.
    imOUT = filter->GetOutput();
    imOUT->DisconnectPipeline();

    ImageType::Pointer im;
    WriteMetaFile("/home/encephalon/puja/testRegion.mhd", imOUT);
     im=Read("/home/encephalon/puja/testRegion.mhd");
     View(im, "region");

}

Thanks for your help,
Puja

--
---------------------------------------
Puja Malik
Surgical Instruments Group
MEM Research Center for Orthopaedic Surgery
Institute for Surgical Technology and Biomechanics
University of Bern
Murtenstrasse 35, P.O. Box 8354
3010 Bern, Switzerland
Phone: +41-31-632-8730
Fax: +41-31-632-4951
Email: Puja.Malik@MEMcenter.unibe.ch
http://www.MEMcenter.unibe.ch
---------------------------------------



--Boundary_(ID_M3zbmFHbwSZ2QnIBPBdFRQ)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi Luis,
<p>I've managed to fix my problem in the ExtractImageFilter.&nbsp; I&nbsp;do
have one concern though.&nbsp; I cannot directly use the image object from
the output of the filter, and view it in the fltk image filter.&nbsp; If
I do this, the images intensity range is altered, and the first slice is
distorted.&nbsp; I&nbsp;must first write the output of the filter ( image
object ) to a file, read it back into a new image object and then view
it.&nbsp; This way, I see a correctly extracted image.&nbsp; This is very
strange.&nbsp; It would be convenient if the output of the filter could
be used directly.&nbsp; Please see my code below, including the extra steps
I needed to perform to get the desired results.
<p>void ExtractImageRegion(ImageType::Pointer imIN, ImageType::SizeType
regSize,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ImageType::IndexType
<br>regIndex)
<br>{
<p>&nbsp;typedef itk::ExtractImageFilter&lt; ImageType, ImageType > FilterType;
<br>&nbsp;FilterType::Pointer filter = FilterType::New();
<br>&nbsp;ImageType::Pointer imOUT;
<p>&nbsp;ImageType::RegionType region;
<br>&nbsp;region.SetSize(regSize);
<br>&nbsp;region.SetIndex(regIndex);
<p>&nbsp;filter->SetExtractionRegion(region);
<br>&nbsp;filter->SetInput(imIN);
<br>&nbsp;filter->Update();
<br>&nbsp;
<br>// View(filter->GetOutput(), "region");&nbsp; &lt;-- doing this directly
shows a distorted image
<p>//the following is the extra steps needed to view a correct image
<br>//View, Read, WriteMetaFile are my own functions written using itk
classes.
<br>&nbsp;&nbsp;&nbsp; imOUT = filter->GetOutput();
<br>&nbsp;&nbsp;&nbsp; imOUT->DisconnectPipeline();
<br>&nbsp;
<br>&nbsp;&nbsp;&nbsp; ImageType::Pointer im;
<br>&nbsp;&nbsp;&nbsp; WriteMetaFile("/home/encephalon/puja/testRegion.mhd",
imOUT);
<br>&nbsp;&nbsp;&nbsp;&nbsp; im=Read("/home/encephalon/puja/testRegion.mhd");
<br>&nbsp;&nbsp;&nbsp;&nbsp; View(im, "region");
<p>}
<p>Thanks for your help,
<br>Puja
<pre></pre>

<pre>--&nbsp;
---------------------------------------
Puja Malik
Surgical Instruments Group
MEM Research Center for Orthopaedic Surgery
Institute for Surgical Technology and Biomechanics&nbsp;
University of Bern
Murtenstrasse 35, P.O. Box 8354
3010 Bern, Switzerland
Phone: +41-31-632-8730
Fax: +41-31-632-4951
Email: Puja.Malik@MEMcenter.unibe.ch
<A HREF="http://www.MEMcenter.unibe.ch">http://www.MEMcenter.unibe.ch</A>
---------------------------------------</pre>
&nbsp;</html>

--Boundary_(ID_M3zbmFHbwSZ2QnIBPBdFRQ)--