[Insight-users] ExtractImageFilter

Puja Malik puja.malik@MEMcenter.unibe.ch
Fri, 31 Jan 2003 16:21:42 +0100


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



> Hi Luis,
>
> I am processing an MR image of meta format.  I've looked at the
> example in the Software Guide, and adapted the code.  To find the
> intensity range, I use the values given in the FLTK viewer, in the
> bottom left hand corner.
>
> Just for clarification:  The region size {x, y, z} would have x, y and
> z being the lengths of the sides of the region right?  Or is this size
> computed like a radius?  And the index is the corner from where the
> specified region would start from right?
>
> Here is my code, perhaps there is something that I am overlooking.  My
> View function displays the image in the FLTK viewer.
>
> void ExtractImageRegion2(ImageType::Pointer imIN, ImageType::SizeType
> regSize,
>        ImageType::IndexType regIndex)
> {
>
>  typedef itk::ExtractImageFilter< ImageType, ImageType > FilterType;
>   FilterType::Pointer filter = FilterType::New();
>
>  ImageType::Pointer imOUT = ImageType::New();
>
>  ImageType::RegionType region;
>  region.SetSize(regSize);
>  region.SetIndex(regIndex);
>
>  filter->SetExtractionRegion(region);
>  filter->SetInput(imIN);
>  filter->GraftOutput(imOUT);
>
>  imOUT = filter->GetOutput();
>
>  try
>     {
>     filter->Update();
>     }
>   catch( itk::ExceptionObject & err )
>     {
>     std::cout << "ExceptionObject caught !" << std::endl;
>     std::cout << err << std::endl;
>
>     }
>
>     try
>     {
>     imOUT->Update();
>     }
>    catch( itk::ExceptionObject & err )
>     {
>     std::cout << "ExceptionObject caught !" << std::endl;
>     std::cout << err << std::endl;
>
>     }
>
>
>  View(imOUT, "this is the region");
> }
>
>
> Thanks for your help!
> Puja
>
>
> Luis Ibanez wrote:
>
>> Hi Puja,
>>
>> The ExtractImageFilter shouldn't be changing
>> the intensity values of the extracted pixels.
>> It is supposed to simply copy their values
>> into a smaller image.
>>
>> What kind of image are you processing ?
>>
>> What method are you using for computing
>> the intensity range ?
>>
>> (e.g. you could use the MinimumMaximumImageCalculator.)
>>
>> BTW an example on the use of the ExtractImageFilter
>> is available under:
>>
>> Insight/Examples/IO/ImageReadExtractWrite.cxx
>>
>> and is described in the SoftwareGuide on the
>> section:
>>
>>       "Reading and Writing Images"
>>
>> You can experiment with it by passing 2D images
>> and providing the index and size in the command
>> line. It reads and writes PNG, DICOM, VTK, and
>> MetaImage formats.
>>
>> Please let us know some more details of what
>> you are doing.
>>
>>    Thanks
>>
>>       Luis
>>
>> ----------------------------------
>> Puja Malik wrote:
>>
>> > Hello,
>> > I'm having trouble using the itk ExtractImageFilter.
>> >
>> > In my implementation, I use an image of size {512,512,30}.  The
>> interger
>> > range in this image is from 0 to 272.  When I extract a region
>> size of
>> > the same size as the image, I get back the correct image.
>> However, if I
>> > set my index as {0,0,0} and extract a region size of {511, 511,
>> 30},
>> > then I get the correct image back, however the interger range is
>> now
>> > from 0 to 4161 and the image appears much dimmer.  It seems that
>> the
>> > smaller I make the region to be extracted, the larger the
>> resulting
>> > image's interger range is.
>> >
>> > Perhaps I'm not understanding the functionality of the
>> > ExtractImageFilter properly.  Does anyone have any idea how I
>> could fix
>> > this?
>> >
>> > Thanks,
>> > 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
>> > ---------------------------------------
>> >
>> >
>
> --
> ---------------------------------------
> 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
> ---------------------------------------
>
>

--
---------------------------------------
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_Bch4SUwOrQXKonx37iQ+vA)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<blockquote TYPE=CITE>Hi Luis,
<p>I am processing an MR image of meta format.&nbsp; I've looked at the
example in the Software Guide, and adapted the code.&nbsp; To find the
intensity range, I use the values given in the FLTK viewer, in the bottom
left hand corner.
<p>Just for clarification:&nbsp; The region size {x, y, z} would have x,
y and z being the lengths of the sides of the region right?&nbsp; Or is
this size computed like a radius?&nbsp; And the index is the corner from
where the specified region would start from right?
<p>Here is my code, perhaps there is something that I am overlooking.&nbsp;
My View function displays the image in the FLTK viewer.
<p>void ExtractImageRegion2(ImageType::Pointer imIN, ImageType::SizeType
regSize,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageType::IndexType regIndex)
<br>{
<p>&nbsp;typedef itk::ExtractImageFilter&lt; ImageType, ImageType > FilterType;
<br>&nbsp; FilterType::Pointer filter = FilterType::New();
<p>&nbsp;ImageType::Pointer imOUT = ImageType::New();
<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->GraftOutput(imOUT);
<p>&nbsp;imOUT = filter->GetOutput();
<p>&nbsp;try
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; filter->Update();
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp; catch( itk::ExceptionObject &amp; err )
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "ExceptionObject caught !" &lt;&lt;
std::endl;
<br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; err &lt;&lt; std::endl;
<p>&nbsp;&nbsp;&nbsp; }
<p>&nbsp;&nbsp;&nbsp; try
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; imOUT->Update();
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp; catch( itk::ExceptionObject &amp; err )
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "ExceptionObject caught !" &lt;&lt;
std::endl;
<br>&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; err &lt;&lt; std::endl;
<p>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;
<p>&nbsp;View(imOUT, "this is the region");
<br>}
<br>&nbsp;
<p>Thanks for your help!
<br>Puja
<br>&nbsp;
<p>Luis Ibanez wrote:
<blockquote TYPE=CITE>Hi Puja,
<p>The ExtractImageFilter shouldn't be changing
<br>the intensity values of the extracted pixels.
<br>It is supposed to simply copy their values
<br>into a smaller image.
<p>What kind of image are you processing ?
<p>What method are you using for computing
<br>the intensity range ?
<p>(e.g. you could use the MinimumMaximumImageCalculator.)
<p>BTW an example on the use of the ExtractImageFilter
<br>is available under:
<p>Insight/Examples/IO/ImageReadExtractWrite.cxx
<p>and is described in the SoftwareGuide on the
<br>section:
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Reading and Writing Images"
<p>You can experiment with it by passing 2D images
<br>and providing the index and size in the command
<br>line. It reads and writes PNG, DICOM, VTK, and
<br>MetaImage formats.
<p>Please let us know some more details of what
<br>you are doing.
<p>&nbsp;&nbsp; Thanks
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis
<p>----------------------------------
<br>Puja Malik wrote:
<p>> Hello,
<br>> I'm having trouble using the itk ExtractImageFilter.
<br>>
<br>> In my implementation, I use an image of size {512,512,30}.&nbsp;
The interger
<br>> range in this image is from 0 to 272.&nbsp; When I extract a region
size of
<br>> the same size as the image, I get back the correct image.&nbsp; However,
if I
<br>> set my index as {0,0,0} and extract a region size of {511, 511, 30},
<br>> then I get the correct image back, however the interger range is
now
<br>> from 0 to 4161 and the image appears much dimmer.&nbsp; It seems
that the
<br>> smaller I make the region to be extracted, the larger the resulting
<br>> image's interger range is.
<br>>
<br>> Perhaps I'm not understanding the functionality of the
<br>> ExtractImageFilter properly.&nbsp; Does anyone have any idea how
I could fix
<br>> this?
<br>>
<br>> Thanks,
<br>> Puja
<br>>
<br>>
<br>> --
<br>> ---------------------------------------
<br>> Puja Malik
<br>> Surgical Instruments Group
<br>> MEM Research Center for Orthopaedic Surgery
<br>> Institute for Surgical Technology and Biomechanics
<br>> University of Bern
<br>> Murtenstrasse 35, P.O. Box 8354
<br>> 3010 Bern, Switzerland
<br>> Phone: +41-31-632-8730
<br>> Fax: +41-31-632-4951
<br>> Email: Puja.Malik@MEMcenter.unibe.ch
<br>> <a href="http://www.MEMcenter.unibe.ch">http://www.MEMcenter.unibe.ch</a>
<br>> ---------------------------------------
<br>>
<br>></blockquote>

<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;</blockquote>

<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_Bch4SUwOrQXKonx37iQ+vA)--