From 026b2fe203089e1917ab78ebafb3131f147223f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Sun, 6 Nov 2016 22:20:22 -0500 Subject: [PATCH] ... --- data/binary_test_2D_00.png | Bin 0 -> 5192 bytes data/ones_image.png | Bin 0 -> 1697 bytes data/workspaces/workspace_airwaysappli.wxml | 73 +++++++++++++++++ lib/fpa/Image/SkeletonFilter.hxx | 85 +++++++++++--------- plugins/CMakeLists.txt | 34 +++----- 5 files changed, 132 insertions(+), 60 deletions(-) create mode 100644 data/binary_test_2D_00.png create mode 100644 data/ones_image.png create mode 100644 data/workspaces/workspace_airwaysappli.wxml diff --git a/data/binary_test_2D_00.png b/data/binary_test_2D_00.png new file mode 100644 index 0000000000000000000000000000000000000000..fbe9d39bd59189ecf7f8ef87e48abde2f3d01953 GIT binary patch literal 5192 zcmaJ_c{G$?_rKE*W zWDUhPDnu%>ge;Y%l-=)4-}5`a|9Hs6i%_YQ*g`DvU@kESG4jyKyy9oe*c&&*6dMxzg_x?|5Us{9> zJ8(DG*RzJK61Hd^RY*Nx-xKxtX5p2@rq}6*O>X7M{WbM>OhJm-h93j4L9N~2cB8#6 z@A25fUyr5*4Mq2w!x0Y>YOJVXy^+{VP3U-flE)6!p#5 zTzM-1Hi$=gf~STO4jqdISDK}=xvt(ZG3Q)Z6kM+;5in+Fqa z9~O!l7rZr?P4F6VWjs%>a3@h0IKo)Vxfdh$KD6ls;_Ie4XdG##&2`M1_?#du&fuj_$gT@;h3GX zMQIvBP%f{{uooe%QvyZ;1VdbjpN#BRdbx&t;oFJB985fIw!VH-BQeaib?(EXLC z!Mn{Zx4O=X$imb=?{pK?5-7>Uf+LZ^Z9$|?6R!GvJNn9{#Rn@`I(>5Kia;v0Wr@(5 zW%V=UpggJ52qtR|UNhu&vqxzCC%X7|NrMCm$E+uAe&NoCX&HkwJv4hMj!j(~^xf$H!^-k%{L8~DeAmOq^Yh&G@s#C;5 zvBjN}HL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sv$zzOW|jLRic=-?KS$%7^fz-1dh`Jb}_;!x&pXEzLfuYWF~eL5xRU5^QE$ zBiP0FY#*rL7*LQ=s!m=JtEKL%_m4Aba~p^wtHGzbm0sj-+-sI;m+4QSv|PFRc&28J z@IfaoqI|l9b@lM9`Rksm(_ICIbE6JBiGfFbP53m zRGMA(735<;I5rFtC=f}LYla7u5}}e=V$%@6;fwub*RP74FT$p3jFbD(dKinLxWjtG z8PfYTn|_$V`-1nUBN}WPrZ<{jp=q#z3DYoIJQMZ|K4+Lp=)e)dfCvt}AK|ro7zV#j zyMwV11tQ_F`Yq=XdGIeXfKb3#WK&<}uUIf}I2Lh+{&V!dasBNgC;sdAJhee_G=CJ2 z)AJ0-eYcSaa*5?g-qZj0&-VWf)1Puf^ofj&#1`p`Y*#7{?v7li9 literal 0 HcmV?d00001 diff --git a/data/ones_image.png b/data/ones_image.png new file mode 100644 index 0000000000000000000000000000000000000000..f7afaab3a8241507fc085fd4450f6bfa393ef4db GIT binary patch literal 1697 zcmeAS@N?(olHy`uVBq!ia0y~yU{(NO4h9AWhJVtLTNoG^I14-?iy0WWg+Z8+Vb&Z8 z1_lQ95>H=O_IupSeA=d~Z^Sw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 -- 2.47.1