X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FIsoImageSlicer.hxx;fp=lib%2FcpExtensions%2FAlgorithms%2FIsoImageSlicer.hxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=041d874864d7fc641cf79240c21aa659b7c0d79c;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx b/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx deleted file mode 100644 index 041d874..0000000 --- a/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx +++ /dev/null @@ -1,234 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__HXX__ -#define __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__HXX__ - -// ------------------------------------------------------------------------- -template< class R, class I > -unsigned long cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GetMTime( ) const -{ - unsigned long t = this->Superclass::GetMTime( ); - unsigned long sT = this->m_Slicer->GetMTime( ); - unsigned long cT = this->m_Collapsor->GetMTime( ); - unsigned long tT = this->m_Transform->GetMTime( ); - t = ( sT > t )? sT: t; - t = ( cT > t )? cT: t; - t = ( tT > t )? tT: t; - return( t ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -const typename cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -TInterpolateFunction* -cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GetInterpolator( ) const -{ - return( this->m_Slicer->GetInterpolator( ) ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -const typename cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -TMatrix& cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GetRotation( ) const -{ - return( this->m_Transform->GetMatrix( ) ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -const typename cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -TVector& cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GetTranslation( ) const -{ - return( this->m_Transform->GetOffset( ) ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -SetInterpolator( TInterpolateFunction* f ) -{ - this->m_Slicer->SetInterpolator( f ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -template< class M > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -SetRotation( const M& r ) -{ - TMatrix rotation; - for( unsigned int i = 0; i < Self::Dim; ++i ) - for( unsigned int j = 0; j < Self::Dim; ++j ) - rotation[ i ][ j ] = r[ i ][ j ]; - this->m_Transform->SetMatrix( rotation ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -template< class V > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -SetTranslation( const V& t ) -{ - TVector off; - for( unsigned int i = 0; i < Self::Dim; ++i ) - off[ i ] = t[ i ]; - this->m_Transform->SetOffset( off ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -SetSize( TScalar s ) -{ - this->m_Size.Fill( s ); - this->Modified( ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -BaseImageSlicer( ) - : Superclass( ), - m_SizeFromMaximum( false ), - m_SizeFromMinimum( false ), - m_Spacing( TSpacingValue( 1 ) ), - m_SpacingFromMaximum( false ), - m_SpacingFromMinimum( false ) -{ - this->m_Size.Fill( TScalar( 1 ) ); - - // Slicer - this->m_Slicer = TSlicer::New( ); - - TIndex idx; - idx.Fill( 0 ); - this->m_Slicer->SetOutputStartIndex( idx ); - - // Dimension collapsor - this->m_Collapsor = TCollapsor::New( ); - this->m_Collapsor->SetInput( this->m_Slicer->GetOutput( ) ); - this->m_Collapsor->SetDirectionCollapseToIdentity( ); - - this->m_Transform = TTransform::New( ); - this->m_Transform->SetIdentity( ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -~BaseImageSlicer( ) -{ -} - -// ------------------------------------------------------------------------- -template< class R, class I > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GenerateOutputInformation( ) -{ -} - -// ------------------------------------------------------------------------- -template< class R, class I > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GenerateInputRequestedRegion( ) -{ - TImage* input = const_cast< TImage* >( this->GetInput( ) ); - if( input != NULL ) - input->SetRequestedRegionToLargestPossibleRegion( ); -} - -// ------------------------------------------------------------------------- -template< class R, class I > -void cpExtensions::Algorithms::BaseImageSlicer< R, I >:: -GenerateData( ) -{ - const TImage* input = this->GetInput( ); - - // Spacing - TSpacing spac; - if( this->m_SpacingFromMaximum || this->m_SpacingFromMinimum ) - { - spac = input->GetSpacing( ); - TSpacingValue minIso = spac[ 0 ]; - TSpacingValue maxIso = spac[ 0 ]; - for( unsigned int i = 1; i < Self::Dim; i++ ) - { - minIso = ( spac[ i ] < minIso )? spac[ i ]: minIso; - maxIso = ( spac[ i ] > maxIso )? spac[ i ]: maxIso; - - } // rof - this->m_Spacing = ( this->m_SpacingFromMinimum )? minIso: maxIso; - - } // fi - spac.Fill( this->m_Spacing ); - - // Size and origin - if( this->m_SizeFromMaximum || this->m_SizeFromMinimum ) - { - TSize iSize = input->GetRequestedRegion( ).GetSize( ); - TSpacing iSpac = input->GetSpacing( ); - TScalar minSize = TScalar( iSize[ 0 ] ) * TScalar( iSpac[ 0 ] ); - TScalar maxSize = minSize; - for( unsigned int i = 1; i < Self::Dim; i++ ) - { - TScalar v = TScalar( iSize[ i ] ) * TScalar( iSpac[ i ] ); - minSize = ( v < minSize )? v: minSize; - maxSize = ( v > maxSize )? v: maxSize; - - } // rof - if( this->m_SizeFromMaximum ) - this->m_Size.Fill( maxSize ); - else - this->m_Size.Fill( minSize ); - - } // fi - - TSize size; - typename TSlicer::OriginPointType origin; - size[ 0 ] = 1; - origin[ 0 ] = 0; - for( unsigned int i = 1; i < Self::Dim; i++ ) - { - double s = double( this->m_Size[ i ] ) / double( spac[ i ] ); - size[ i ] = ( unsigned int )( s ); - origin[ i ] = -( 0.5 * this->m_Size[ i ] ); - - } // rof - - // Prepare slicer - this->m_Slicer->SetInput( input ); - this->m_Slicer->SetTransform( this->m_Transform ); - this->m_Slicer->SetOutputSpacing( spac ); - this->m_Slicer->SetOutputOrigin( origin ); - this->m_Slicer->SetSize( size ); - this->m_Slicer->SetDefaultPixelValue( this->m_DefaultValue ); - - // Slice! - // Note: UpdateLargestPossibleRegion( ) is used since we need the - // output regions to be updated at each filter call. - this->m_Slicer->UpdateLargestPossibleRegion( ); - - // Collapse result - TRegion region = this->m_Slicer->GetOutput( )->GetRequestedRegion( ); - TSize regionSize = region.GetSize( ); - regionSize[ 0 ] = 0; - region.SetSize( regionSize ); - this->m_Collapsor->SetExtractionRegion( region ); - - this->m_Collapsor->GraftOutput( this->GetOutput( ) ); - this->m_Collapsor->UpdateLargestPossibleRegion( ); - this->GraftOutput( this->m_Collapsor->GetOutput( ) ); -} - -#endif // __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__HXX__ - -// eof - $RCSfile$