### Eclipse Workspace Patch 1.0 #P ITK_3_4_0 Index: Code/BasicFilters/itkRegionOfInterestImageFilter.txx =================================================================== RCS file: /cvsroot/Insight/Insight/Code/BasicFilters/itkRegionOfInterestImageFilter.txx,v retrieving revision 1.15 diff -u -r1.15 itkRegionOfInterestImageFilter.txx --- Code/BasicFilters/itkRegionOfInterestImageFilter.txx 1 Aug 2006 19:16:18 -0000 1.15 +++ Code/BasicFilters/itkRegionOfInterestImageFilter.txx 16 May 2008 09:39:14 -0000 @@ -3,7 +3,7 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkRegionOfInterestImageFilter.txx,v $ Language: C++ - Date: $Date: 2006-08-01 19:16:18 $ + Date: $Date: 2006/08/01 19:16:18 $ Version: $Revision: 1.15 $ Copyright (c) Insight Software Consortium. All rights reserved. @@ -63,12 +63,22 @@ // get pointer to the input typename Superclass::InputImagePointer inputPtr = const_cast< TInputImage * >( this->GetInput() ); + OutputImagePointer outputPtr = this->GetOutput(); - if( inputPtr ) + if ( !inputPtr || !outputPtr ) { - // request the region of interest - inputPtr->SetRequestedRegion( m_RegionOfInterest ); + return; } + + // If the requested region is smaller / contained in m_RegionOfInterest + // then the inputRequestedRegion is cropped to match the requested region + // Otherwise (can this happen?) the inputRequestedRegion is + // NOT cropped and is equal to the m_RegionOfInterest + typename TInputImage::RegionType inputRequestedRegion( m_RegionOfInterest ); + inputRequestedRegion.Crop( outputPtr->GetRequestedRegion() ); + inputRequestedRegion.Crop( inputPtr->GetLargestPossibleRegion() ); // is this really needed? + + inputPtr->SetRequestedRegion( inputRequestedRegion ); } template @@ -79,8 +89,12 @@ // call the superclass' implementation of this method Superclass::EnlargeOutputRequestedRegion(output); - // generate everything in the region of interest - output->SetRequestedRegionToLargestPossibleRegion(); + // Why setting requested region to largest possible region?? + // Input requested region is calculated in GenerateInputRequestedRegion () + // according to output requested region. Setting the output to the + // largest possible region will set the input requested region to the + // input largest possible region and it is not what we want!? + // output->SetRequestedRegionToLargestPossibleRegion(); } Index: Code/BasicFilters/itkShrinkImageFilter.txx =================================================================== RCS file: /cvsroot/Insight/Insight/Code/BasicFilters/itkShrinkImageFilter.txx,v retrieving revision 1.53 diff -u -r1.53 itkShrinkImageFilter.txx --- Code/BasicFilters/itkShrinkImageFilter.txx 19 Mar 2006 04:36:56 -0000 1.53 +++ Code/BasicFilters/itkShrinkImageFilter.txx 16 May 2008 09:39:14 -0000 @@ -3,7 +3,7 @@ Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkShrinkImageFilter.txx,v $ Language: C++ - Date: $Date: 2006-03-19 04:36:56 $ + Date: $Date: 2006/03/19 04:36:56 $ Version: $Revision: 1.53 $ Copyright (c) Insight Software Consortium. All rights reserved. @@ -204,11 +204,20 @@ typename TInputImage::IndexType inputRequestedRegionStartIndex; for (i = 0; i < TInputImage::ImageDimension; i++) - { - inputRequestedRegionSize[i] - = outputRequestedRegionSize[i] * m_ShrinkFactors[i]; + { inputRequestedRegionStartIndex[i] - = outputRequestedRegionStartIndex[i] * (long)m_ShrinkFactors[i]; + = outputRequestedRegionStartIndex[i] * (size_t)m_ShrinkFactors[i]; + + // To optimize computation time and specially memory footprint + if (outputRequestedRegionSize[i] == 1) + { + inputRequestedRegionSize[i] = 1; + } + else + { + inputRequestedRegionSize[i] + = outputRequestedRegionSize[i] * (size_t)m_ShrinkFactors[i]; + } } typename TInputImage::RegionType inputRequestedRegion; @@ -228,8 +237,12 @@ // call the superclass' implementation of this method Superclass::EnlargeOutputRequestedRegion(output); - // generate everything in the region of interest - output->SetRequestedRegionToLargestPossibleRegion(); + // Why setting requested region to largest possible region?? + // Input requested region is calculated in GenerateInputRequestedRegion () + // according to output requested region. Setting the output to the + // largest possible region will set the input requested region to the + // input largest possible region and it is not what we want!? + // output->SetRequestedRegionToLargestPossibleRegion(); }