1 // =======================================================================
2 // @author: Leonardo Florez-Valencia
3 // @email: florez-l@javeriana.edu.co
4 // =======================================================================
5 #ifndef __ivq__ITK__RegionOfInterestWithPaddingImageFilter__hxx__
6 #define __ivq__ITK__RegionOfInterestWithPaddingImageFilter__hxx__
8 // -------------------------------------------------------------------------
9 template< class _TInput, class _TOutput >
10 ivq::ITK::RegionOfInterestWithPaddingImageFilter< _TInput, _TOutput >::
11 RegionOfInterestWithPaddingImageFilter( )
17 // -------------------------------------------------------------------------
18 template< class _TInput, class _TOutput >
19 ivq::ITK::RegionOfInterestWithPaddingImageFilter< _TInput, _TOutput >::
20 ~RegionOfInterestWithPaddingImageFilter( )
24 // -------------------------------------------------------------------------
25 template< class _TInput, class _TOutput >
26 void ivq::ITK::RegionOfInterestWithPaddingImageFilter< _TInput, _TOutput >::
27 GenerateOutputInformation( )
29 if( this->m_Padding > 0 )
32 typename _TInput::RegionType region =
33 this->GetInput( )->GetLargestPossibleRegion( );
34 typename _TInput::RegionType roi = this->GetRegionOfInterest( );
35 typename _TInput::IndexType iMin = region.GetIndex( );
36 typename _TInput::IndexType iMax = iMin + region.GetSize( );
37 typename _TInput::IndexType i0 = roi.GetIndex( );
38 typename _TInput::IndexType i1 = i0 + roi.GetSize( );
39 typename _TInput::SizeType size;
40 for( unsigned int d = 0; d < _TInput::ImageDimension; ++d )
42 i0[ d ] -= this->m_Padding;
43 i1[ d ] += this->m_Padding;
44 i0[ d ] = ( i0[ d ] < iMin[ d ] )? iMin[ d ]: i0[ d ];
45 i1[ d ] = ( iMax[ d ] < i1[ d ] )? iMax[ d ]: i1[ d ];
46 size[ d ] = i1[ d ] - i0[ d ];
52 this->SetRegionOfInterest( roi );
55 this->Superclass::GenerateOutputInformation( );
58 #endif // __ivq__ITK__RegionOfInterestWithPaddingImageFilter__hxx__