X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FSpatialObjectMaskImageFilter.hxx;fp=lib%2FcpExtensions%2FAlgorithms%2FSpatialObjectMaskImageFilter.hxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=2c3cac73f33b2fdbd39d060dd5d5d036a0df1e11;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx b/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx deleted file mode 100644 index 2c3cac7..0000000 --- a/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef __CPEXTENSIONS__ALGORITHMS__SPATIALOBJECTMASKIMAGEFILTER__HXX__ -#define __CPEXTENSIONS__ALGORITHMS__SPATIALOBJECTMASKIMAGEFILTER__HXX__ - -#include -#include - -// ------------------------------------------------------------------------- -template< class I, class O > -O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -GetPositiveOutput( ) -{ - return( this->GetOutput( 0 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -const O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -GetPositiveOutput( ) const -{ - return( this->GetOutput( 0 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -GetNegativeOutput( ) -{ - return( this->GetOutput( 1 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -const O* cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -GetNegativeOutput( ) const -{ - return( this->GetOutput( 1 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -SpatialObjectMaskImageFilter( ) - : Superclass( ) -{ - this->SetNumberOfRequiredInputs( 1 ); - this->SetNumberOfRequiredOutputs( 2 ); - this->SetNthOutput( 0, O::New( ) ); - this->SetNthOutput( 1, O::New( ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O > -cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -~SpatialObjectMaskImageFilter( ) -{ -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -GenerateOutputInformation( ) -{ - const I* in = - dynamic_cast< const I* >( this->itk::ProcessObject::GetInput( 0 ) ); - for( unsigned int idx = 0; idx < this->GetNumberOfOutputs( ); ++idx ) - { - itk::DataObject* out = this->GetOutput( idx ); - if( out ) - out->CopyInformation( in ); - - } // rof -} - -// ------------------------------------------------------------------------- -template< class I, class O > -void cpExtensions::Algorithms::SpatialObjectMaskImageFilter< I, O >:: -ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) -{ - if( this->m_SpatialObject.IsNull( ) ) - { - itkGenericExceptionMacro( << "No itk::SpatialObject given." ); - return; - - } // fi - - // Get inputs - const I* in = - dynamic_cast< const I* >( this->itk::ProcessObject::GetInput( 0 ) ); - O* pos_out = this->GetPositiveOutput( ); - O* neg_out = this->GetNegativeOutput( ); - const auto size0 = region.GetSize( 0 ); - if( size0 == 0 ) - return; - const auto nLines = region.GetNumberOfPixels( ) / size0; - - // Create iterators - itk::ImageScanlineConstIterator< I > iIt( in, region ); - itk::ImageScanlineIterator< O > pos_oIt( pos_out, region ); - itk::ImageScanlineIterator< O > neg_oIt( neg_out, region ); - itk::ProgressReporter progress( this, threadId, nLines ); - - // Main loop - typename TSpatialObject::PointType pnt; - while( !iIt.IsAtEnd( ) ) - { - while( !iIt.IsAtEndOfLine( ) ) - { - auto idx = iIt.GetIndex( ); - in->TransformIndexToPhysicalPoint( idx, pnt ); - if( this->m_SpatialObject->IsInside( pnt ) ) - { - pos_oIt.Set( TOutPixel( iIt.Get( ) ) ); - neg_oIt.Set( this->m_OutsideValue ); - } - else - { - neg_oIt.Set( TOutPixel( iIt.Get( ) ) ); - pos_oIt.Set( this->m_OutsideValue ); - - } // fi - ++iIt; - ++pos_oIt; - ++neg_oIt; - - } // elihw - iIt.NextLine( ); - pos_oIt.NextLine( ); - neg_oIt.NextLine( ); - progress.CompletedPixel( ); - - } // elihw -} - -#endif // __CPEXTENSIONS__ALGORITHMS__SPATIALOBJECTMASKIMAGEFILTER__HXX__ - -// eof - $RCSfile$