<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi,<div><br></div><div>i took a look to your code and i am newbie but i think that you have to define the same region (inputRegion and desiredRegion should be the same i mean... doing sth like this it works).</div><div><code></div><div><span class="Apple-tab-span" style="white-space:pre">        ImageType::RegionType _region = img->GetLargestPossibleRegion();
ImageType::IndexType _index = _region.GetIndex();
_index[0] = 110;
_index[1] = 95;
_index[2] = 25;
ImageType::SizeType _size = _region.GetSize();
_size[0] = 35;
_size[1] = 55;
_size[2] = 10;
_region.SetIndex( _index );
_region.SetSize( _size );
extractFilter->SetExtractionRegion( _region );
try
{
extractFilter->Update();
}
catch( itk::ExceptionObject &e )
{
std::cerr << e.GetDescription() << std::endl;
exit( EXIT_FAILURE );
}</span></div><div></code> </div><div>Another option could be that the error could appear when defining the size (SizeType) and the start (IndexType). </div><div><br></div><div>hope it helps.</div><div>Alba<br><div>
<p align="center"><font color="#000000"><img height="2" src="http://graphics.hotmail.com/greypixel.gif" width="100%" vspace="9"></font></p></div><br><br><br><br><hr id="stopSpelling">Date: Thu, 10 Mar 2011 10:39:45 +0100<br>From: meluks2010@googlemail.com<br>To: insight-users@itk.org<br>Subject: [Insight-users] InvalidRequestedRegionError with ExtractImageFilter<br><br>Hi all,<br><br>I try to extract a slide of a 3D image with the ExtractImageFilter. I mainly used the code I found in the Software Guide under "7.7 Extracting Slices". I always get this error:<br><br><span style="color:rgb(255, 0, 0)"> itk::InvalidRequestedRegionError (0153BF38)</span><br style="color:rgb(255, 0, 0)">
<span style="color:rgb(255, 0, 0)"> Location: "void __thiscall itk::DataObject::PropagateRequestedRegion(void) throw (class itk::InvalidRequestedRegionError)"</span><br style="color:rgb(255, 0, 0)"><span style="color:rgb(255, 0, 0)"> File: ..\..\InsightToolkit-3.16.0\Code\Common\itkDataObject.cxx</span><br style="color:rgb(255, 0, 0)">
<span style="color:rgb(255, 0, 0)"> Line:397</span><br style="color:rgb(255, 0, 0)"><span style="color:rgb(255, 0, 0)"> Description: Requested region is (at least partially outside the largest possible region.</span><br>
<br>The image is a global variable and used with several (itk) functions. One of those is the ExtractImageFilter.<br>This is the code:<br><br> <span style="font-family:courier new,monospace"> typedef itk::Image<PixelType, 2> OutputImageType; //dimension</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> typedef itk::ExtractImageFilter<ImageType, OutputImageType> ExtractFilterType;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> ExtractFilterType::Pointer extractFilter = ExtractFilterType::New();</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> ImageType::RegionType inputRegion = image->GetLargestPossibleRegion(); //image size</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> ImageType::SizeType size = inputRegion.GetSize();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> size[1]=0; //y-Dimension wird gelöscht</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> ImageType::IndexType start = inputRegion.GetIndex(); </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> start[1]=slice; //constant y-value</span><br style="font-family:courier new,monospace">
<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> ImageType::RegionType desiredRegion; //region of the slide in the 3D inage</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> desiredRegion.SetSize(size);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> desiredRegion.SetIndex(start);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> extractFilter->SetExtractionRegion(desiredRegion); //add region to filter</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> extractFilter->SetInput(image); //Input: image</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> OutputImageType::Pointer outimage = OutputImageType::New();</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> </span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> try</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> extractFilter->Update(); //filtering</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> outimage = extractFilter->GetOutput();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> }</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> catch(itk::ExceptionObject &err)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> {</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> std::cerr << "ExeptionObject caught!" << std::endl;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> std::cerr << "Image2QImage Slice extract." << std::endl;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace"> std::cerr << err << std::endl;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"> }</span><br>
<br>It would be great if someone knows what I have to change to avoid the error.<br>Thanks in advance!<br>Regards<br><br>melanie<br>
<br>_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users</div>                                            </body>
</html>