11 #ifndef BIOPROCESSING_WATERSHED_COUSTY 12 #define BIOPROCESSING_WATERSHED_COUSTY 19 #include <aims/vector/vector.h> 21 #include <cartodata/volume/volume.h> 23 #include <cartobase/config/verbose.h> 38 template <
typename T,
typename L>
67 carto::VolumeRef<L>
execute( carto::VolumeRef<T> in );
70 void execute( carto::VolumeRef<T> in, carto::VolumeRef<L> out );
83 bool findEdge( Vertex y, Vertex & z );
100 template <
typename T,
typename L>
103 carto::VolumeRef<L> out( in.getSizeX(), in.getSizeY(),
104 in.getSizeZ(), in.getSizeT() );
105 out->copyHeaderFrom( in.header() );
110 template <
typename T,
typename L>
112 carto::VolumeRef<L> out )
115 _g =
Graph( in, aims::strel::Connectivity6XYZ() );
117 _g =
Graph( in, aims::strel::Connectivity4XY() );
119 _psi.setVolume( out );
124 template <
typename T,
typename L>
130 typename FlowMap::iterator i;
133 long size =
_psi.size();
135 std::cout << std::endl;
136 for( i =
_psi.begin() ; i !=
_psi.end(); ++i )
138 if(
_verbose && ( ++j % 10000 == 0 ) )
139 std::cout <<
"\rVertex: " << j <<
"/" << size << std::flush;
142 if( lab ==
_psi.labelNone() )
145 if( lab ==
_psi.labelMinus() )
153 std::cout << std::endl <<
"Labels created: " << nb_labs << std::endl;
156 template <
typename T,
typename L>
162 _psi.setLabel( *i, lab );
166 template <
typename T,
typename L>
179 breadth_first =
true;
180 while( breadth_first &&
findEdge( y, z ) )
183 if( lab !=
_psi.labelNone() )
189 breadth_first =
false;
199 return _psi.labelMinus();
202 template <
typename T,
typename L>
221 #endif // BIOPROCESSING_WATERSHED_COUSTY CoustyFlowMapRef< Vertex, L > FlowMap
FlowMap type (the labelled image)
virtual Weight weight(const Edge &e)
carto::VolumeRef< L > getMinima()
CoustyStreamRef< Vertex > Stream
Stream type (a set of vertices)
void computeWatershed()
Iterates on the vertices of the image, and for each one follows a descent stream until it encounters ...
void set3D()
When 3D mode is active, a 3D connectivity is used (6XYZ)
virtual Weight Fm(const Vertex &v) const
void setLabel(L lab)
Sets the label lab for all vertices in the stream _s.
Pointed::edge_iterator edge_iterator
edge_const_iterator beginEdge(const Vertex &v) const
std::pair< iterator, bool > insert(const Vertex &v)
void setVerbose(int verbose=1)
Graph::Vertex Vertex
Vertex type.
vertex_const_iterator endVertex() const
void set2D()
When 2D mode is active, a 2D connectivity is used (4XY)
const_iterator end() const
size_t count(const Vertex &v) const
const_iterator begin() const
bool findEdge(Vertex y, Vertex &z)
Finds an edge of minimum altitude for y.
Pointed::iterator iterator
vertex_const_iterator beginVertex() const
VolumeGraphRef< T, Point > Graph
Graph type.
Graph::Edge Edge
Edge type.
Point4dl Point
Point type.
L computeStream(Vertex x)
Follows the descent stream from vertex v.
carto::VolumeRef< L > execute(carto::VolumeRef< T > in)
Allocate and return the watershed segmentation of the input image.
edge_const_iterator endEdge(const Vertex &v) const
void erase(const Vertex &v)
Watershed implementation as described in Cousty et al - Watershed cuts: minimum spanning forests and ...