Introduction to graphs and their ability to represent images

25
Introduction to Graphs and their Ability to Represent Images Martin Cerman

Transcript of Introduction to graphs and their ability to represent images

Page 1: Introduction to graphs and their ability to represent images

Introduction to Graphs and their Ability to Represent Images

Martin Cerman

Page 2: Introduction to graphs and their ability to represent images

•  Graph G = (V,E) •  Set of vertices V

•  Set of edges E, where E ⊂  V x V

•  Edges can be directed or undirected

Graph Definition

2  

V = {1, 2, 3, 4, 5} E = {(1,2), (2,3), (3,2), (4,3), (4,1), (4,5), (5,5)}

1  2  

3  

4  

5  

1

1

=  

Page 3: Introduction to graphs and their ability to represent images

•  Parallel / Double edges

•  Self-loops

•  Simple graph: contains NO parallel edges and NO self-loops

•  Multigraph: contains parallel edges and/or self-loops

Graph Definition

3  

Page 4: Introduction to graphs and their ability to represent images

•  Planar graphs •  Contains no crossing edges

•  Tree •  Connects all vertices without cycles

•  Forest •  All connected components are trees

Graph Definition

4  

Page 5: Introduction to graphs and their ability to represent images

•  Vertices generally stored in array or vector

•  Most common data-structures to store edges •  Adjacency list

•  Adjacency matrix

•  Incidence matrix

•  Edge data-structure defines complexity of graph operations •  Storage- and computational cost

•  Operations for example: add edge, remove edge, check adjacency,…

Graph Data-structure

5  

Page 6: Introduction to graphs and their ability to represent images

•  Collection of unordered linked lists, one for each vertex

•  Great for representation of sparse graphs

Adjacency List

6  

1  2  

3  

4  

5  

1 2 3 4 5

2 3 2 1 5

4 3

5

Graph  opera*on   Complexity  

Store  graph   O(|V|+|E|)  

Add  Vertex   O(1)  

Add  Edge   O(1)  

Remove  Vertex   O(|E|)  

Remove  Edge   O(|E|)  

Adjacency  check   O(|V|)  

V

Page 7: Introduction to graphs and their ability to represent images

•  Square matrix with side length |V|

•  Describes if two vertices are adjacent

•  Symmetric if undirected graph, binary if simple graph

Adjacency Matrix

7  

1  2  

3  

4  

5  

Graph  opera*on   Complexity  

Store  graph   O(|V|²)  

Add  Vertex   O(|V|²)  

Add  Edge   O(1)  

Remove  Vertex   O(|V|²)  

Remove  Edge   O(1)  

Adjacency  check   O(1)  

1  

1  

1   1  

1   1   1  

1  

V

V

Page 8: Introduction to graphs and their ability to represent images

•  Matrix of size |V| x |E|

•  Describes incidence relationship between vertices and edges

Incidence Matrix

8  

1  2  

3  

4  

5  

Graph  opera*on   Complexity  

Store  graph   O(|V|*|E|)  

Add  Vertex   O(|V|*|E|)  

Add  Edge   O(|V|*|E|)  

Remove  Vertex   O(|V|*|E|)  

Remove  Edge   O(|V|*|E|)  

Adjacency  check   O(|E|)  

1   2   3   4   5  

a   1   1  

b   1   1  

c   1   1  

d   1   1  

e   1   1  

f   1  

V

E

c

b

d

a

e f

Page 9: Introduction to graphs and their ability to represent images

Complexity Comparison

9  

Adjacency  List   Adjacency  Matrix   Incidence  Matrix  

Store  graph   O(|V|+|E|)   O(|V|²)   O(|V|*|E|)  

Add  Vertex   O(1)   O(|V|²)   O(|V|*|E|)  

Add  Edge   O(1)   O(1)   O(|V|*|E|)  

Remove  Vertex   O(|E|)   O(|V|²)   O(|V|*|E|)  

Remove  Edge   O(|E|)   O(1)   O(|V|*|E|)  

Adjacency  check   O(|V|)   O(1)   O(|E|)  

•  Choose data-structure based on algorithm needs !

Page 10: Introduction to graphs and their ability to represent images

•  Vertex merging (Edge contraction)

•  Edge removal

Graph Reduction Operations

10  

Page 11: Introduction to graphs and their ability to represent images

•  Built by applying reduction operations to a graph

•  Lowest level stores original graph

•  Top level stores maximally reduced graph (single vertex)

Graph Pyramid

11  

Page 12: Introduction to graphs and their ability to represent images

•  Vertices describe pixels

•  Edges describe adjacency relationships between pixels •  4-connected image graph is always planar

Graphs and Images

12  

Page 13: Introduction to graphs and their ability to represent images

•  Simplified image graph

•  Vertices describe connected regions of any shape and size

•  Edges describe adjacency relationships between regions

•  Simple graph – no multiple edges, no self-loops

Region Adjacency Graph

13  

Page 14: Introduction to graphs and their ability to represent images

•  Does not uniquely describe a “setting” of regions

•  Cannot describe inclusion relationship and multiple borders

Region Adjacency Graph

14  

Page 15: Introduction to graphs and their ability to represent images

•  Every planar graph has a dual graph

•  Primal graph •  Vertices describe regions

•  Edges describe adjacency relationships between regions

•  Dual graph •  Vertices describe faces

•  Edges describe borders of faces

Dual Graphs

15  

Page 16: Introduction to graphs and their ability to represent images

•  Primal edge contraction = dual edge removal

•  Primal edge removal = dual edge contraction

Duality of Reduction Operations

16  

Page 17: Introduction to graphs and their ability to represent images

•  Differentiates between adjacency and inclusion relationship

•  Preserves multiple borders

Dual Graphs

17  

1  

4  

Page 18: Introduction to graphs and their ability to represent images

•  Differentiates between adjacency and inclusion relationship

•  Preserves multiple borders

•  Does not uniquely describe a “setting” of regions

Dual Graphs

18  

1  

4  

Page 19: Introduction to graphs and their ability to represent images

•  Different representation of a graph

•  Combinatorial Map CM = (D, α, σ) •  Set of “darts” D

•  α involution connecting two darts

•  σ permutation connecting two darts

•  Can be stored in single array

Combinatorial Maps

19  

1  

2  3   4  

σ  

α  

Page 20: Introduction to graphs and their ability to represent images

•  Modification of the σ permutation

•  Vertex merging (edge contraction)

•  Edge removal

CM Reduction Operations

20  

Page 21: Introduction to graphs and their ability to represent images

•  Primal combinatorial map implicitly stores dual map CM’=(D, α, γ) •  Dual map can be computed anytime from the primal, and vice-versa

•  Combination of α involution and σ permutation

•  γ  = (α * σ)      or    γ  = (σ  *  α)

Dual Combinatorial Maps

21  

Page 22: Introduction to graphs and their ability to represent images

Combinatorial Maps

22  

Page 23: Introduction to graphs and their ability to represent images

•  Uniquely describe “setting” of regions •  Because of implicitly storing direction of darts around each vertex

Dual Combinatorial Maps

23  

Page 24: Introduction to graphs and their ability to represent images

•  Task: group pixels with “similar” properties •  Color, texture, higher level features,…

•  Iterative Approach: •  Represent image as graph

•  Assign weights to edges (similarity)

•  Iteratively contract edges with lowest weights

•  Other approaches: •  Minimum spanning tree based approaches

•  Graph cuts

Application: Image Segmentation

24  

Page 25: Introduction to graphs and their ability to represent images

Thank you!

Martin Cerman