X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FCommon%2FSliceBySliceRandomWalker.hxx;h=3b86d023b9b56f65de65e71121648c6fafce3025;hb=463b1ec45c70ca63aa9f19f8cb58ae5d5134e56b;hp=c0bc3ff516e51fe83c2f85239b7ea14cbce3d1f9;hpb=9817c556a0b8b5e3b332d45f07faa84d91afb2d0;p=FrontAlgorithms.git diff --git a/lib/fpa/Common/SliceBySliceRandomWalker.hxx b/lib/fpa/Common/SliceBySliceRandomWalker.hxx index c0bc3ff..3b86d02 100644 --- a/lib/fpa/Common/SliceBySliceRandomWalker.hxx +++ b/lib/fpa/Common/SliceBySliceRandomWalker.hxx @@ -6,6 +6,7 @@ #define __fpa__Common__SliceBySliceRandomWalker__hxx__ #include +#include #include #include #include @@ -106,6 +107,8 @@ GenerateData( ) typename _TJoin::Pointer join = _TJoin::New( ); for( int i = 0; i < numSlices; ++i ) join->SetInput( i, binaryTree[ i ] ); + join->SetOrigin( input->GetOrigin( )[ 2 ] ); + join->SetSpacing( input->GetSpacing( )[ 2 ] ); join->Update( ); this->GetOutput( )->Graft( join->GetOutput( ) ); } @@ -197,7 +200,7 @@ _RandomWalker( // Create seeds and background _TSliceBinaryPtr seeds = _TSliceBinary::New( ); seeds->CopyInformation( tmp ); - seeds->SetRequestedRegion( region ); + seeds->SetBufferedRegion( region ); seeds->Allocate( ); seeds->FillBuffer( 0 ); @@ -250,10 +253,19 @@ _RandomWalker( rw->SetInputLabels( seeds ); rw->SetEdgeFunction( edge ); + // Extract label + typedef itk::BinaryThresholdImageFilter< _TSliceBinary, _TSliceBinary > _TExtract; + typename _TExtract::Pointer extract = _TExtract::New( ); + extract->SetInput( rw->GetOutput( ) ); + extract->SetInsideValue( 1 ); + extract->SetOutsideValue( 0 ); + extract->SetLowerThreshold( 1 ); + extract->SetUpperThreshold( 1 ); + // Keep maximum typedef itk::MaximumImageFilter< _TSliceBinary > _TMax; typename _TMax::Pointer max = _TMax::New(); - max->SetInput( 0, rw->GetOutput( ) ); + max->SetInput( 0, extract->GetOutput( ) ); max->SetInput( 1, next ); max->Update( ); binaryTree[ z + o ] = max->GetOutput( );