Public Types | Public Member Functions

TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType > Class Template Reference

Segmentation of simply connected spaces in 3D data. More...

#include <RegionGrowing3D.hpp>

List of all members.

Public Types

typedef BinaryDataType binary_value_type
typedef LabelType label_type
typedef Coordinate< unsigned > Point
typedef std::deque< PointRegion
typedef std::deque< Region > Regions

Public Member Functions

 RegionGrowing3D ()
 RegionGrowing3D (BinaryFieldType data, const unsigned width, const unsigned height, const unsigned depth)
virtual ~RegionGrowing3D ()
void setData (BinaryFieldType data, const unsigned width, const unsigned height, const unsigned depth)
void setNeighborhoodSize (const unsigned size)
template<int StrideX, int StrideY, int StrideZ>
void compute ()
 Performs the region growing.
void compute ()
void compute (const Point &seed_point)
 Performs the region growing.
void compute (const std::deque< Point > &seed_points)
 Performs the region growing.
const Regions & getRegions () const
const LabelType * getLabelMask () const

Detailed Description

template<class BinaryDataType, class LabelType = unsigned short, class BinaryFieldType = const BinaryDataType *>
class TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >

Segmentation of simply connected spaces in 3D data.

Template Parameters:
BinaryDataTypeData type of the binary mask.
LabelTypeData type of the label mask (should be able to hold the number of segmented regions).
BinaryFieldTypeField type of the binary data. This allows overloading operator[]().

Segmentation of simply connected spaces in 3D data. The segmentation is done fully automatically, i.e. no seed points need to be provided (though, they can be provided). The result of the region growing is a label mask and a list of regions where, again, each region consists of a list of points forming the respective region.

Points are considered to be connected if they are lying in the same neighborhood, where a neighborhood \( \cal{N}\) is defined as

\[ \cal{N} \left( (x_0, y_0, z_0) \right) := \left\{ (x, y, z) \; | \; (x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 \le c \right\} \]

The parameter \( c \) can be set by setNeighborhoodSize(); its default value is 2.

Here is an example of how to use this class:

 #include <iostream>

 #include "TRTK/RegionGrowing3D.hpp"


 using namespace std;
 using namespace TRTK;


 const unsigned WIDTH  = 7;
 const unsigned HEIGHT = 5;
 const unsigned DEPTH  = 2;

 bool data[WIDTH * HEIGHT * DEPTH] = {0, 0, 0, 0, 0, 0, 1,
                                      0, 1, 1, 0, 0, 0, 0,
                                      0, 1, 1, 0, 0, 0, 0,
                                      0, 0, 0, 0, 0, 1, 1,
                                      0, 0, 0, 0, 0, 1, 1,

                                      0, 0, 0, 0, 0, 0, 0,
                                      0, 1, 1, 0, 0, 0, 0,
                                      0, 0, 1, 0, 0, 0, 0,
                                      0, 0, 0, 0, 0, 1, 1,
                                      0, 0, 0, 0, 0, 1, 1};

 int main()
 {
     // Print the data.

     cout << "Data" << endl << endl;

     for (unsigned d = 0; d < DEPTH; ++d)
     {
         for (unsigned m = 0; m < HEIGHT; ++m)
         {
             for (unsigned n = 0; n < WIDTH; ++n)
             {
                 cout << data[d * WIDTH * HEIGHT + m * WIDTH + n] << "  ";
             }
             cout << endl;
         }
         cout << endl << endl;
     }

     // Perform the region growing.

     RegionGrowing3D<bool> regionGrowing3D(data, WIDTH, HEIGHT, DEPTH);
     regionGrowing3D.setNeighborhoodSize(2);
     regionGrowing3D.compute();

     // Print the label mask.

     cout << endl << "Label mask" << endl << endl;

     const RegionGrowing3D<bool>::label_type * label_mask = regionGrowing3D.getLabelMask();

     for (unsigned d = 0; d < DEPTH; ++d)
     {
         for (unsigned m = 0; m < HEIGHT; ++m)
         {
             for (unsigned n = 0; n < WIDTH; ++n)
             {
                 cout << label_mask[d * WIDTH * HEIGHT + m * WIDTH + n] << "  ";
             }
             cout << endl;
         }
         cout << endl << endl;
     }

     // Print the regions.

     cout << endl << "Regions" << endl << endl;

     for (unsigned label = 0; label < regionGrowing3D.getRegions().size(); ++label)
     {
         for (unsigned i = 0; i < regionGrowing3D.getRegions()[label].size(); ++i)
         {
             cout << regionGrowing3D.getRegions()[label][i] << "  ";
         }
         cout << endl;
     }

     return 0;
 }

Output:

 Data

 0  0  0  0  0  0  1
 0  1  1  0  0  0  0
 0  1  1  0  0  0  0
 0  0  0  0  0  1  1
 0  0  0  0  0  1  1


 0  0  0  0  0  0  0
 0  1  1  0  0  0  0
 0  0  1  0  0  0  0
 0  0  0  0  0  1  1
 0  0  0  0  0  1  1



 Label mask

 0  0  0  0  0  0  1
 0  2  2  0  0  0  0
 0  2  2  0  0  0  0
 0  0  0  0  0  3  3
 0  0  0  0  0  3  3


 0  0  0  0  0  0  0
 0  2  2  0  0  0  0
 0  0  2  0  0  0  0
 0  0  0  0  0  3  3
 0  0  0  0  0  3  3



 Regions

 (6, 0, 0)
 (1, 1, 0)  (1, 1, 1)  (1, 2, 0)  (2, 1, 0)  (2, 1, 1)  (2, 2, 0)  (2, 2, 1)
 (5, 3, 0)  (5, 3, 1)  (5, 4, 0)  (5, 4, 1)  (6, 3, 0)  (6, 3, 1)  (6, 4, 0)  (6, 4, 1)
See also:
RegionGrowing2D
Author:
Christoph Haenisch
Version:
0.4.0
Date:
last changed on 2012-07-05

Definition at line 204 of file RegionGrowing3D.hpp.


Constructor & Destructor Documentation

template<class BinaryDataType , class LabelType , class BinaryFieldType >
TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::RegionGrowing3D (  )

Constructs an instance of RegionGrowing3D.

Definition at line 251 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType>
TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::RegionGrowing3D ( BinaryFieldType  data,
const unsigned  width,
const unsigned  height,
const unsigned  depth 
)
Parameters:
[in]data3D data
[in]widthnumber of columns of data
[in]heightnumber of rows of data
[in]depthnumber of planes of data

Constructs an instance of RegionGrowing3D.

Definition at line 271 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType >
TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::~RegionGrowing3D (  ) [virtual]

Destructs the instance of RegionGrowing3D.

Definition at line 287 of file RegionGrowing3D.hpp.


Member Function Documentation

template<class BinaryDataType , class LabelType , class BinaryFieldType >
template<int StrideX, int StrideY, int StrideZ>
void TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::compute (  )

Performs the region growing.

All potential regions within the data set are extracted. The region growing depends on the size of the neighborhood. The result is a label mask and a list of regions which again are lists consisting of points of the respective regions.

See also:
setNeighborhoodSize(), getLabelMask(), getRegions()
Template Parameters:
StrideXStep size in x while traversing the data.
StrideYStep size in y while traversing the data.
StrideZStep size in z while traversing the data.

All potential regions within the data set are extracted. The region growing depends on the size of the neighborhood. The result is a label mask and a list of regions which again are lists consisting of points of the respective regions.

The template parameters StrideX, StrideY and StrideZ specify the step size with which the binary mask is traversed while searching for potential seed points. This may lead to a significant speed-up. However, structures may be missed if their dimensions are smaller than these sizes.

See also:
setNeighborhoodSize(), getLabelMask(), getRegions()

Definition at line 304 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType >
void TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::compute ( const Point seed_point )

Performs the region growing.

Parameters:
[in]seed_pointStarting point for region growing.

Only a single region is extracted. The region growing depends on the size of the neighborhood. The result is a label mask and a list of regions which again are lists consisting of points of the respective regions.

See also:
setNeighborhoodSize(), getLabelMask(), getRegions()

Definition at line 499 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType >
void TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::compute ( const std::deque< Point > &  seed_points )

Performs the region growing.

Parameters:
[in]seed_pointsList of seed points.

A seed point is a starting point from which a region is grown up. Only those regions are extracted from which one or more points are in the list of seed points. The region growing depends on the size of the neighborhood. The result is a label mask and a list of regions which again are lists consisting of points of the respective regions.

See also:
setNeighborhoodSize(), getLabelMask(), getRegions()

Definition at line 521 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType >
const LabelType * TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::getLabelMask (  ) const

A label mask is returned, whose entries denote, to which region a datum in data belongs to.

Returns:
Pointer to the label mask or NULL if no region growing has been performed, yet.

Definition at line 624 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType >
const RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::Regions & TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::getRegions (  ) const [inline]
Returns:
Returns a list with regions, where again each region consists of a list of points lying in this particular region.

Definition at line 702 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType>
void TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::setData ( BinaryFieldType  data,
const unsigned  width,
const unsigned  height,
const unsigned  depth 
)
Parameters:
[in]data3D data
[in]widthnumber of columns of data
[in]heightnumber of rows of data
[in]depthnumber of planes of data

Sets the binary image as well as its width, height and depth.

Definition at line 732 of file RegionGrowing3D.hpp.

template<class BinaryDataType , class LabelType , class BinaryFieldType >
void TRTK::RegionGrowing3D< BinaryDataType, LabelType, BinaryFieldType >::setNeighborhoodSize ( const unsigned  size )
Parameters:
[in]sizeSize of the neighborhood.

Sets the size \( c \) of the neighborhood \( \cal{N}\) of a point \( (x_0, y_0, z_0) \), where the neighborhood is defined as

\[ \cal{N} \left( (x_0, y_0, z_0) \right) := \left\{ (x, y, z) \; | \; (x - x_0)^2 + (y - y_0)^2 + (z - z_0)^2 \le c \right\} \]

Definition at line 759 of file RegionGrowing3D.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines