84 ImageNode() : b(0), g(0), r(0), l(0),
n(1), id(0), max_w(0) {
104 unsigned long int id;
127 nodes = std::vector<ImageNode>(N);
152 nodes.push_back(node);
160 edges.push_back(edge);
168 assert(n >= 0 && n < static_cast<int>(nodes.size()));
176 assert(e >= 0 && e < static_cast<int>(edges.size()));
261 std::vector<ImageEdge> edges;
264 std::vector<ImageNode> nodes;
void sortEdges()
Sort the edges by weight.
Definition: image_graph.h:202
unsigned long int n
Size of node after merging with other nodes.
Definition: image_graph.h:101
int getNumComponents()
Get number of connected components.
Definition: image_graph.h:196
float max_w
Maximum weight.
Definition: image_graph.h:107
int getNumEdges()
Get the number of edges.
Definition: image_graph.h:190
Represents a pixel in a video. Each pixel is represented by its color which is needed to compute the ...
Definition: image_graph.h:80
void addNode(ImageNode &node)
Add a new node.
Definition: image_graph.h:151
ImageGraph()
Default constructor.
Definition: image_graph.h:119
unsigned char b
Blue channel.
Definition: image_graph.h:86
void operator=(const ImageGraph &graph)
Assignment operator.
Definition: image_graph.h:134
unsigned long int n
Index of first node.
Definition: image_graph.h:48
ImageNode & getNode(int n)
Definition: image_graph.h:167
ImageGraph(int N)
Constructs an image graph with the given exact number of nodes.
Definition: image_graph.h:126
Class for sorting edges according to weight.
Definition: image_graph.h:64
unsigned long int m
Index of second node.
Definition: image_graph.h:54
unsigned char r
Red channel.
Definition: image_graph.h:95
unsigned char g
Green channel.
Definition: image_graph.h:92
void setNode(int n, ImageNode &node)
Set the node of the given index.
Definition: image_graph.h:144
unsigned long int l
The label of the pixel.
Definition: image_graph.h:98
Represents an image graph, consisting of one node per pixel which are 4-connected.
Definition: image_graph.h:115
ImageNode & findNodeComponent(ImageNode &n)
When two nodes get merged, the first node is assigned the id of the second node as label...
Definition: image_graph.h:213
int getNumNodes()
Get the number of nodes.
Definition: image_graph.h:183
float w
Edge weight.
Definition: image_graph.h:57
ImageEdge & getEdge(int e)
Get the e-th edge in the current sorting.
Definition: image_graph.h:175
Represents an edge between two pixels in an image. Each edge is characterized by a weight and the adj...
Definition: image_graph.h:44
bool operator()(const ImageEdge &g, const ImageEdge h)
Compare to edges according to their weights.
Definition: image_graph.h:71
unsigned long int id
Id of the node.
Definition: image_graph.h:104
ImageNode()
Default constructor.
Definition: image_graph.h:84
ImageEdge()
Default constructor.
Definition: image_graph.h:48
void addEdge(ImageEdge &edge)
Add a new edge.
Definition: image_graph.h:159
void merge(ImageNode &S_n, ImageNode &S_m, ImageEdge &e)
Merge two pixels (that is merge two nodes).
Definition: image_graph.h:242