#include <itkImageScanlineIterator.h>
#include <itkProgressReporter.h>
+// -------------------------------------------------------------------------
+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 >::
: Superclass( )
{
this->SetNumberOfRequiredInputs( 1 );
- this->InPlaceOff( );
+ this->SetNumberOfRequiredOutputs( 2 );
+ this->SetNthOutput( 0, O::New( ) );
+ this->SetNthOutput( 1, O::New( ) );
}
// -------------------------------------------------------------------------
// 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;
// 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
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