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