Hello to all,<br><br>I am reading a 3D image using a reader, then I rescale the volume using RescaleIntensityImageFilter, then extract a subregion from the rescaled volume and finally I extract slices from this subregion. But every time I am daclare the input region for the extract  slice Image Filter then I get an exception I hope that someone could help me.<br>
<br>Thanks in advance<br><br>  typedef float               InputPixelType;<br>  typedef unsigned char       OutputPixelType;<br>  const   unsigned int        Dimension = 3;<br><br>  typedef itk::Image&lt; InputPixelType,  Dimension &gt;    InputImageType;<br>
  typedef itk::Image&lt; OutputPixelType, Dimension &gt;    OutputImageType;<br><br>  typedef itk::ImageFileReader&lt; InputImageType  &gt;  ReaderType;<br><br>   typedef itk::RegionOfInterestImageFilter&lt; OutputImageType, <br>
                                            OutputImageType &gt; FilterType_region;<br><br>  typedef itk::RescaleIntensityImageFilter&lt; <br>                                 InputImageType, <br>                                  OutputImageType &gt;    FilterType_rescale;<br>
  typedef  unsigned char        InputPixelType_extract;<br>  typedef unsigned char        OutputPixelType_extract;<br>  typedef itk::Image&lt; InputPixelType_extract,  3 &gt;    InputImageType_extract;<br>  typedef itk::Image&lt; OutputPixelType_extract, 2 &gt;    OutputImageType_extract;<br>
   typedef itk::ExtractImageFilter&lt; InputImageType_extract, OutputImageType_extract &gt; FilterType_extract;<br>///////////////////////////////////////////////////<br>/////////////////////////////////////<br><br><br>   FilterType_rescale::Pointer filter_rescale = FilterType_rescale::New();<br>
       filter_rescale-&gt;SetOutputMinimum(   0 );<br>       filter_rescale-&gt;SetOutputMaximum( value_norm );<br><br>//////extract region filter<br>       FilterType_region::Pointer filter_region = FilterType_region::New();<br>
        OutputImageType::IndexType start_region;<br>        start_region[0] = ui-&gt;doubleSpinBox_start_x-&gt;value();<br>        start_region[1] = ui-&gt;doubleSpinBox_start_y-&gt;value();<br>        start_region[2] = ui-&gt;doubleSpinBox_start_z-&gt;value();<br>
<br>        OutputImageType::SizeType size_region;<br>        size_region[0] = ui-&gt;doubleSpinBox_size_x-&gt;value();<br>        size_region[1] = ui-&gt;doubleSpinBox_size_y-&gt;value();<br>        size_region[2] = ui-&gt;doubleSpinBox_size_z-&gt;value();<br>
<br>        OutputImageType::RegionType desiredRegion_region;<br>        desiredRegion_region.SetSize(  size_region  );<br>        desiredRegion_region.SetIndex( start_region );<br><br>        filter_region-&gt;SetRegionOfInterest( desiredRegion_region );<br>
<br>        ReaderType::Pointer reader = ReaderType::New();<br><br>        reader-&gt;SetFileName( fileName.toStdString()  );<br><br>        filter_rescale-&gt;SetInput( reader-&gt;GetOutput() );<br>        filter_region-&gt;SetInput( filter_rescale-&gt;GetOutput() );<br>
<br>        filter_region-&gt;Update();<br><br>      /////////////////////<br>  FilterType_extract::Pointer filter_extract = FilterType_extract::New();<br><span style="background-color: rgb(255, 255, 51);">        </span><br style="background-color: rgb(255, 255, 51);">
<span style="background-color: rgb(255, 255, 51);">  OutputImageType::RegionType inputRegion =</span><br style="background-color: rgb(255, 255, 51);"><span style="background-color: rgb(255, 255, 51);">          filter_region-&gt;GetOutput()-&gt;GetLargestPossibleRegion();</span><br>
<br>  OutputImageType::SizeType size = inputRegion.GetSize();<br> <br>  // get the size of the hole 3D image<br>  size_x = size[0];<br>  size_y = size[1];<br>  size_z = size[2];<br>  <br>  // get slices of z coordiante<br>
  size[2] = 0; <br><br>   OutputImageType::IndexType start = inputRegion.GetIndex();<br><br>  ui-&gt;verticalScrollBar_z-&gt;setRange(0,size_z-1);<br>  unsigned int sliceNumber = ui-&gt;verticalScrollBar_z-&gt;value();<br>
  start[2] = sliceNumber;<br> <br><br>  OutputImageType::RegionType desiredRegion;<br>  desiredRegion.SetSize( size );<br>  desiredRegion.SetIndex( start );<br><br>  filter_extract-&gt;SetExtractionRegion( desiredRegion );<br>
<br>     WriterType::Pointer writer = WriterType::New();<br>    writer-&gt;SetFileName( &quot;z.png&quot; );<br>   <br>  filter_extract-&gt;SetInput( filter_region-&gt;GetOutput() );<br>   writer-&gt;SetInput( filter_extract-&gt;GetOutput() );<br>
<br>    try <br>    { <br>    writer-&gt;Update(); <br>    } <br>  catch( itk::ExceptionObject &amp; err ) <br>    { <br>    std::cerr &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; <br>    std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>
    } <br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>