CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image...
Transcript of CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image...
![Page 1: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/1.jpg)
CS3000:Algorithms&DataJonathanUllman
Lecture21:MoreApplicationsofNetworkFlow
Nov30,2018
![Page 2: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/2.jpg)
ImageSegmentation
![Page 3: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/3.jpg)
ImageSegmentation
• Separateimageintoforegroundandbackground• Wehavesomeideaof:• whetherpixeliisintheforegroundorbackground• whetherpair(i,j)arelikelytogotogether
![Page 4: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/4.jpg)
ImageSegmentation
• Input:• adirectedgraph! = ($, &);$ =“pixels”,& =“pairs”• likelihoods(), *) ≥ 0 forevery- ∈ $• separationpenalty/)0 ≥ 0 forevery -, 1 ∈ &
• Output:• apartitionof$ into 2, 3 thatmaximizes
4 2, 3 = 6()�
)∈8+6*0
�
0∈:− 6 /)0
�
),0 ∈<=>?@8A?:
O O OI F IOes O O OF I I0 O O O
foreggand background
Lquality
![Page 5: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/5.jpg)
ReductiontoMinCut• DifferencesbetweenSEGandMINCUT:• SEGasksustomaximize,MINCUTasksustominimize
• SEG allowsanypartition,MINCUTrequiresB ∈ 2,C ∈ 3
max8,: 6()�
)∈8+6*0
�
0∈:− 6 /)0
�
),0 ∈<=>?@8A?:
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
max g ASB nfib g ASBA B
miner graph has nodeVoss 13
MinA B partitioning
cap A0553 Bose
Add two nodes sit
![Page 6: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/6.jpg)
ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
min 2 cap i ji j EEA B fromA to B
![Page 7: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/7.jpg)
ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
A AB cap Auss Busts
IzabitjEsa's PijfromAtoB
Assume Gonly has nodes
i j3
![Page 8: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/8.jpg)
ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
A B
so
![Page 9: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/9.jpg)
Step1:TransformtheInput
InputG,{a,b,p}forSEG
InputG’forMINCUT
so
time 0 mtn
![Page 10: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/10.jpg)
Step2:ReceivetheOutput
Solve
InputG’forMINCUT
Output(A,B)forMINCUTA
time time to solveMsn art on a graph
ath
Nt 2 nodes
B2n t m edges
0 nm time
![Page 11: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/11.jpg)
Step3:TransformtheOutput
Output(A,B)forSEG
Output(A,B)forMINCUT
i
on
![Page 12: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/12.jpg)
ReductiontoMinCut• correctness?
• runningtime?
Max gCA BA B
itransform its Y 3 thief D0 ntm t O nm t 0 n
O nm
![Page 13: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/13.jpg)
DensestSubgraph
![Page 14: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/14.jpg)
ImageSegmentation
• Wanttoidentifycommunitiesinanetwork• “Community”:asetofnodesthathavealotofconnectionsinsideandfewoutside
MMMMMMMe Community Detection
![Page 15: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/15.jpg)
DensestSubgraph
• Input:• anundirectedgraph! = $, &
• Output:• asubsetofnodes2 ⊆ $ thatmaximizesJ < 8,8
|8|
Fund AB
E AB u u c E o UEA E B
IECA A I
why not maxmax.m.zed.by on edgeA
![Page 16: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/16.jpg)
ReductiontoMinCut• Differentobjectives
• find 2, 3 tomaximizeJ < 8,88
• find 2, 3 tominimize & 2, 3
• SupposeJ < 8,88 ≥ Landseewhatthatimplies
⇔ 2 & 2, 2 ≥ L 2⇔ ΣP∈8 deg T − & 2, 3 ≥ L 2⇔ ΣP∈U deg T − ΣP∈: deg T − & 2, 3 ≥ L 2⇔ 2 & − ΣP∈: deg T − & 2, 3 ≥ L 2⇔ ΣP∈: deg T + L 2 + & 2, 3 ≤ 2 &
We will solve the yeshoquestion is there a communitywith density s S
r
Mincut if c e i
Ea ai t.E.bit.ci eeiaiii
![Page 17: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/17.jpg)
ReductiontoMinCut
ΣP∈WX deg T + Y Z + & Z, Z[ ≤ 2 &
Ive the yeshoquestion is there a communitywith density 8
MinCut if c e i
Ea ai Fersbi t.ci eeiaiiiO
If deg v
21ECA A IIECA B I
![Page 18: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/18.jpg)
ReductiontoMinCut
ΣP∈WX deg T + Y Z + & Z, Z[ ≤ 2 &
We will solve the yeshoquestion is there a communitywith density s S
r
Mincut if c e i
Ea ai t.E.bit.ci eeiaiij
Zpsdeg r uEa8 e.iFeECaiD I
![Page 19: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/19.jpg)
Edge-DisjointPaths
Ezeizagsxoffft ff ffff.BE
![Page 20: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/20.jpg)
(Edge)DisjointPaths• Input: directedgraph! = $, &, B, C• Output: alargestsetofedge-disjoints-tpaths• Asetofs-tpaths\],… , \_ isedgedisjointifthepathsdonotshareanyedges
Alargesetofdisjointpathsmeanswecantolerateedgefailures.
s t
EBAY.IR tHBF AfEfsd2E
![Page 21: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/21.jpg)
BipartiteMatching
• Thereisareductionthatusesintegermaximums-tflow tosolveedgedisjointpaths.
![Page 22: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/22.jpg)
Step1:TransformtheInput
InputGforEDP InputG’forMAXFLOW
s t s t
![Page 23: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/23.jpg)
Step2:ReceivetheOutput
SolveA
InputG’forMAXFLOW
OutputfforMAXFLOW
Red arrowmeansf(e)=1Blackmeans f(e)=0
s t
![Page 24: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/24.jpg)
Step3:TransformtheOutput
OutputMforMCBM
OutputfforMAXFLOW
![Page 25: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/25.jpg)
Correctness• EasyDirection:Iftherearekedgedisjointpathsthenthereisaflowofvaluek
s t
![Page 26: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/26.jpg)
Correctness• HarderDirection:Ifthereisaflowofvaluek,thentherearekedgedisjointpaths
s t
![Page 27: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/27.jpg)
RunningTime• Needtoanalyzethetimefor:• (1)ProducingG’givenG• (2)FindingamaximumflowinG’• (3)ProducingMgivenG’
![Page 28: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/28.jpg)
Summary
• CansolveedgedisjointpathsintimeO(nm)usingFord-Fulkerson
Solvingmaximums-tflowinagraphwithnnodesandmedgesandc(e)=1 intimeT
SolvingedgedisjointpathsinagraphwithnnodesandmedgesintimeT+O(mn)
![Page 29: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/29.jpg)
(Node)DisjointPaths• Input: directedgraph! = $, &, B, C• Output: alargestsetofnode-disjoints-tpaths• Asetofs-tpaths\],… , \_ isnode-disjointifthepathsdonotshareanynodes
Alargesetofdisjointpathsmeanswecantolerateedge failures.
s t
![Page 30: CS3000: Algorithms & Data Jonathan Ullman · 2018-12-06 · Image Segmentation •Separate image into foreground and background •We have some idea of: •whether pixel i is in the](https://reader030.fdocuments.us/reader030/viewer/2022040721/5e2e849f646f4923e741a644/html5/thumbnails/30.jpg)
Step1:TransformtheInput
InputGforNDP InputG’forEDP
s t s t