Public Member Functions | Private Member Functions | Private Attributes | List of all members
connected_components Class Reference

Use row-by-row labeling algorithm to label connected components. The algorithm makes two passes over the image: one pass to record equivalences and assign temporary labels and the second to replace each temporary label by the label of its equivalence class. Based on Linda G. Shapiro, Computer Vision: Theory and Applications. (3.4 Connected Components Labeling), Rosenfeld and Pfaltz (1966). More...

#include <connected_components.h>

Public Member Functions

valarray< int > compactLabeling ()
 Rearrange the labels to make the label numbers consecutive. More...
 
 connected_components (valarray< int > m, int rows, int cols, bool zeroAsBg)
 Constructor that initializes the private member variables. More...
 
void constructBinaryImages (int robotsLabel)
 Create binary arrays of connected labels. More...
 
int getMaxLabel ()
 Get the max label of the labeling process which is in the range [0,max_label]. More...
 
vector< int > labeling ()
 Label the connected components. More...
 
valarray< float > NormalizedEuclideanDistanceBinary (bool RobotR)
 Calculate the normalized euclidean distance transform of a binary image with foreground pixels set to 1 and background set to 0. More...
 
int uf_find (int x, vector< int > parent, vector< int > &label)
 Return the root label (starts from 1 because label array is initialized to 0 at first). The label array records the new label for every root. More...
 
void uf_union (int x, int y, vector< int > &parent)
 Combine two labels. More...
 

Private Member Functions

void DT1D (vector< float > f, vector< float > &d, vector< int > &v, vector< float > &z)
 DT1D. More...
 
vector< float > getVector (valarray< float > A, int row)
 Get a slice of an array. More...
 

Private Attributes

valarray< int > BinaryNonRobot
 Binary array of the labels not assigned to a robot. More...
 
valarray< int > BinaryRobot
 Binary array of the label assigned to a robot. More...
 
int cols
 Number of columns of the image. More...
 
vector< int > image
 The image to perform the labeling on. More...
 
valarray< int > label2d
 Array of labels. More...
 
int next_label = 1
 The current label ID. More...
 
int rows
 Number of rows of the image. More...
 
bool zeroAsBg
 Whether 0 should be considered or not. More...
 

Detailed Description

Use row-by-row labeling algorithm to label connected components. The algorithm makes two passes over the image: one pass to record equivalences and assign temporary labels and the second to replace each temporary label by the label of its equivalence class. Based on Linda G. Shapiro, Computer Vision: Theory and Applications. (3.4 Connected Components Labeling), Rosenfeld and Pfaltz (1966).

Definition at line 14 of file connected_components.h.

Constructor & Destructor Documentation

◆ connected_components()

connected_components::connected_components ( valarray< int >  m,
int  rows,
int  cols,
bool  zeroAsBg 
)

Constructor that initializes the private member variables.

Parameters
mThe matrix containing the data to label.
rowsNumber of rows in the matrix.
colsNumber of columns in the matrix.
zeroAsBgWhether 0 represents background and is ignored.

Definition at line 3 of file connected_components.cpp.

Member Function Documentation

◆ compactLabeling()

valarray< int > connected_components::compactLabeling ( )

Rearrange the labels to make the label numbers consecutive.

Returns
An array of labels.

Definition at line 11 of file connected_components.cpp.

◆ constructBinaryImages()

void connected_components::constructBinaryImages ( int  robotsLabel)

Create binary arrays of connected labels.

Parameters
robotsLabelThe label to create the binary array for.

Definition at line 138 of file connected_components.cpp.

◆ DT1D()

void connected_components::DT1D ( vector< float >  f,
vector< float > &  d,
vector< int > &  v,
vector< float > &  z 
)
private

DT1D.

Parameters
f
d
v
z

Definition at line 203 of file connected_components.cpp.

◆ getMaxLabel()

int connected_components::getMaxLabel ( )

Get the max label of the labeling process which is in the range [0,max_label].

Returns
The maximum label.

Definition at line 41 of file connected_components.cpp.

◆ getVector()

vector< float > connected_components::getVector ( valarray< float >  A,
int  row 
)
private

Get a slice of an array.

Parameters
AThe array to take the slice from.
rowThe index of the slice to take.
Returns
The selected slice.

Definition at line 231 of file connected_components.cpp.

◆ labeling()

vector< int > connected_components::labeling ( )

Label the connected components.

Returns
An array of labels.

Definition at line 46 of file connected_components.cpp.

◆ NormalizedEuclideanDistanceBinary()

valarray< float > connected_components::NormalizedEuclideanDistanceBinary ( bool  RobotR)

Calculate the normalized euclidean distance transform of a binary image with foreground pixels set to 1 and background set to 0.

Parameters
RobotRWhether to compute the distances to the robot.
Returns
The distance array.

Definition at line 155 of file connected_components.cpp.

◆ uf_find()

int connected_components::uf_find ( int  x,
vector< int >  parent,
vector< int > &  label 
)

Return the root label (starts from 1 because label array is initialized to 0 at first). The label array records the new label for every root.

Parameters
xThe label to start the search from.
parentThe label hierarchy.
labelThe vector of labels.
Returns
The root label.

Definition at line 126 of file connected_components.cpp.

◆ uf_union()

void connected_components::uf_union ( int  x,
int  y,
vector< int > &  parent 
)

Combine two labels.

Parameters
xThe first label.
yThe second label.
parentThe label hierarchy.

Definition at line 113 of file connected_components.cpp.

Member Data Documentation

◆ BinaryNonRobot

valarray<int> connected_components::BinaryNonRobot
private

Binary array of the labels not assigned to a robot.

Definition at line 106 of file connected_components.h.

◆ BinaryRobot

valarray<int> connected_components::BinaryRobot
private

Binary array of the label assigned to a robot.

Definition at line 101 of file connected_components.h.

◆ cols

int connected_components::cols
private

Number of columns of the image.

Definition at line 116 of file connected_components.h.

◆ image

vector<int> connected_components::image
private

The image to perform the labeling on.

Definition at line 126 of file connected_components.h.

◆ label2d

valarray<int> connected_components::label2d
private

Array of labels.

Definition at line 96 of file connected_components.h.

◆ next_label

int connected_components::next_label = 1
private

The current label ID.

Definition at line 121 of file connected_components.h.

◆ rows

int connected_components::rows
private

Number of rows of the image.

Definition at line 111 of file connected_components.h.

◆ zeroAsBg

bool connected_components::zeroAsBg
private

Whether 0 should be considered or not.

Definition at line 131 of file connected_components.h.


The documentation for this class was generated from the following files:


area_division
Author(s): Micha Sende
autogenerated on Thu Oct 31 2019 09:22:46