X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FSpatialObjectMaskImageFilter.hxx;h=2c3cac73f33b2fdbd39d060dd5d5d036a0df1e11;hb=f1747c7248d5eead5ea9d7e57bda0b081bcef065;hp=2df9c6f652848afef28af4b596abbb5c92911267;hpb=7478fcc087fe32cee83c18bd98ccf8afb2e8818b;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx b/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx index 2df9c6f..2c3cac7 100644 --- a/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx +++ b/lib/cpExtensions/Algorithms/SpatialObjectMaskImageFilter.hxx @@ -4,6 +4,38 @@ #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 >:: @@ -11,7 +43,9 @@ SpatialObjectMaskImageFilter( ) : Superclass( ) { this->SetNumberOfRequiredInputs( 1 ); - this->InPlaceOff( ); + this->SetNumberOfRequiredOutputs( 2 ); + this->SetNthOutput( 0, O::New( ) ); + this->SetNthOutput( 1, O::New( ) ); } // ------------------------------------------------------------------------- @@ -52,7 +86,8 @@ ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) // Get inputs const I* in = dynamic_cast< const I* >( this->itk::ProcessObject::GetInput( 0 ) ); - O* out = this->GetOutput( 0 ); + O* pos_out = this->GetPositiveOutput( ); + O* neg_out = this->GetNegativeOutput( ); const auto size0 = region.GetSize( 0 ); if( size0 == 0 ) return; @@ -60,7 +95,8 @@ ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) // Create iterators itk::ImageScanlineConstIterator< I > iIt( in, region ); - itk::ImageScanlineIterator< O > oIt( out, 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 @@ -72,15 +108,24 @@ ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) auto idx = iIt.GetIndex( ); in->TransformIndexToPhysicalPoint( idx, pnt ); if( this->m_SpatialObject->IsInside( pnt ) ) - oIt.Set( TOutPixel( iIt.Get( ) ) ); + { + pos_oIt.Set( TOutPixel( iIt.Get( ) ) ); + neg_oIt.Set( this->m_OutsideValue ); + } else - oIt.Set( this->m_OutsideValue ); + { + neg_oIt.Set( TOutPixel( iIt.Get( ) ) ); + pos_oIt.Set( this->m_OutsideValue ); + + } // fi ++iIt; - ++oIt; + ++pos_oIt; + ++neg_oIt; } // elihw iIt.NextLine( ); - oIt.NextLine( ); + pos_oIt.NextLine( ); + neg_oIt.NextLine( ); progress.CompletedPixel( ); } // elihw