From: Leonardo Flórez-Valencia Date: Mon, 7 Nov 2016 03:20:22 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=026b2fe203089e1917ab78ebafb3131f147223f5;p=FrontAlgorithms.git ... --- diff --git a/data/binary_test_2D_00.png b/data/binary_test_2D_00.png new file mode 100644 index 0000000..fbe9d39 Binary files /dev/null and b/data/binary_test_2D_00.png differ diff --git a/data/ones_image.png b/data/ones_image.png new file mode 100644 index 0000000..f7afaab Binary files /dev/null and b/data/ones_image.png differ diff --git a/data/workspaces/workspace_airwaysappli.wxml b/data/workspaces/workspace_airwaysappli.wxml new file mode 100644 index 0000000..9b80164 --- /dev/null +++ b/data/workspaces/workspace_airwaysappli.wxml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/fpa/Image/SkeletonFilter.hxx b/lib/fpa/Image/SkeletonFilter.hxx index fa78819..010c694 100644 --- a/lib/fpa/Image/SkeletonFilter.hxx +++ b/lib/fpa/Image/SkeletonFilter.hxx @@ -3,6 +3,7 @@ #include #include +#include // ------------------------------------------------------------------------- #define fpa_Image_SkeletonFilter_InputMacro( i_n, i_t, i_i ) \ @@ -107,6 +108,7 @@ GenerateData( ) // 2. Detect end-points this->_EndPoints( dmap, cmap, mst, ep->Get( ) ); + std::cout << "endpoints" << std::endl; // 3. Build skeleton and keep track of bifurcations this->_Skeleton( dmap, cmap, mst, ep->Get( ), bi->Get( ), sk ); @@ -126,10 +128,11 @@ _EndPoints( typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt; typedef std::multimap< double, TIndex, std::greater< double > > _TQueue; typedef typename _TQueue::value_type _TQueueValue; - typedef itk::Image< unsigned char, _TCostMap::ImageDimension > _TMarks; + typedef itk::ImageRegionIteratorWithIndex< TMarks > _TMarksIt; + + static const double _eps = std::sqrt( double( TMarks::ImageDimension + 1 ) ); // Some values - // typename _TMarks::Pointer marks = _TMarks::New( ); auto marks = this->GetMarks( ); marks->SetLargestPossibleRegion( dmap->GetLargestPossibleRegion( ) ); marks->SetRequestedRegion( dmap->GetRequestedRegion( ) ); @@ -149,7 +152,7 @@ _EndPoints( for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt ) { double d = double( dIt.Get( ) ); - if( d > 0 ) + if( d > double( 0 ) ) { double v = double( cIt.Get( ) ) / ( d * d ); queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) ); @@ -169,16 +172,18 @@ _EndPoints( queue.erase( nIt ); unsigned char m = marks->GetPixel( n.second ); - // if( ( m & 0x01 ) == 0x01 ) - if( m != 0 || ( n.first / init_v ) < double( 1e-1 ) ) + if( m != 0 ) continue; + std::cout << queue.size( ) << std::endl; + // Mark it and update end-points m |= 0x01; marks->SetPixel( n.second, m ); end_points.insert( n.second ); - // Get path + // Mark path + auto spac = marks->GetSpacing( ); typename TMST::TPath::Pointer path; mst->GetPath( path, n.second ); for( unsigned long i = 0; i < path->GetSize( ); ++i ) @@ -186,41 +191,43 @@ _EndPoints( TIndex idx = path->GetVertex( i ); typename _TCostMap::PointType cnt; cmap->TransformIndexToPhysicalPoint( idx, cnt ); - double d = double( 2 ) * double( dmap->GetPixel( idx ) ); + double r = double( dmap->GetPixel( idx ) ) * _eps; + + TIndex i0, i1; + for( unsigned int d = 0; d < TMarks::ImageDimension; ++d ) + { + long off = long( std::ceil( r / double( spac[ d ] ) ) ); + if( off == 0 ) + off = 1; + i0[ d ] = idx[ d ] - off; + i1[ d ] = idx[ d ] + off; + + if( i0[ d ] < region.GetIndex( )[ d ] ) + i0[ d ] = region.GetIndex( )[ d ]; - // Mark sphere - std::queue< TIndex > q; - q.push( idx ); - while( q.size( ) > 0 ) + if( i1[ d ] >= region.GetIndex( )[ d ] + region.GetSize( )[ d ] ) + i1[ d ] = region.GetIndex( )[ d ] + region.GetSize( )[ d ] - 1; + + } // rof + + typename TMarks::SizeType size; + for( unsigned int d = 0; d < TMarks::ImageDimension; ++d ) + size[ d ] = i1[ d ] - i0[ d ] + 1; + + typename TMarks::RegionType neighRegion; + neighRegion.SetIndex( i0 ); + neighRegion.SetSize( size ); + + _TMarksIt mIt( marks, neighRegion ); + for( mIt.GoToBegin( ); !mIt.IsAtEnd( ); ++mIt ) { - TIndex v = q.front( ); - q.pop( ); - unsigned char m = marks->GetPixel( v ); - if( ( m & 0x02 ) == 0x02 ) - continue; - m |= 0x02; - marks->SetPixel( v, m ); - - for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x ) - { - for( int y = -1; y <= 1; y += 2 ) - { - TIndex w = v; - w[ x ] += y; - if( region.IsInside( w ) ) - { - typename _TCostMap::PointType p; - cmap->TransformIndexToPhysicalPoint( w, p ); - if( cnt.EuclideanDistanceTo( p ) <= d ) - q.push( w ); - - } // fi - - } // rof - - } // rof - - } // elihw + TIndex w = mIt.GetIndex( ); + typename _TCostMap::PointType p; + marks->TransformIndexToPhysicalPoint( w, p ); + if( cnt.EuclideanDistanceTo( p ) <= r ) + mIt.Set( mIt.Get( ) | 0x02 ); + + } // rof } // rof diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index bbc5d32..36271c8 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -2,26 +2,18 @@ ## == Build plugin library == ## ========================== -INCLUDE_DIRECTORIES( - ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_BINARY_DIR}/lib - ) -CreatePlugin(fpaPlugins Plugins ${cpPlugins_CONFIG_NUMBER_OF_FILES}) -TARGET_LINK_LIBRARIES( - fpaPlugins - cpPlugins cpExtensions - ${cpPlugins_Instances} - ${fpa_Instances} - ) - -#IF(USE_cpPlugins) -# Wrap_cpPlugins( -# _plugin -# ${CMAKE_CURRENT_SOURCE_DIR}/Plugins -# ${prj_VERSION} ${prj_SHORT_VERSION} -# fpa -# ) -# TARGET_LINK_LIBRARIES(${_plugin} ${VTK_LIBRARIES} ${cpPlugins_LIB} ${cpPlugins_ImageIterators_LIB} ${fpa_Instances}) -#ENDIF(USE_cpPlugins) +IF(USE_cpPlugins) + INCLUDE_DIRECTORIES( + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_BINARY_DIR}/lib + ) + CreatePlugin(fpaPlugins Plugins ${cpPlugins_CONFIG_NUMBER_OF_FILES}) + TARGET_LINK_LIBRARIES( + fpaPlugins + cpPlugins cpExtensions + ${cpPlugins_Instances} + ${fpa_Instances} + ) +ENDIF(USE_cpPlugins) ## eof - $RCSfile$ \ No newline at end of file