Q&A of GrabCut Philipp Krhenbhl 1 6-May-13 - - PowerPoint PPT Presentation

q a of grabcut
SMART_READER_LITE
LIVE PREVIEW

Q&A of GrabCut Philipp Krhenbhl 1 6-May-13 - - PowerPoint PPT Presentation

Q&A of GrabCut Philipp Krhenbhl 1 6-May-13 Lecture 1 - Philipp Krhenbhl Goal Bounding Box provided 2 6-May-13 Philipp


slide-1
SLIDE 1

Lecture 1 -

  • Philipp Krähenbühl

Q&A ¡of ¡GrabCut ¡

Philipp ¡Krähenbühl ¡

6-­‑May-­‑13 ¡ 1 ¡

slide-2
SLIDE 2

Lecture 1 -

  • Philipp Krähenbühl

Goal ¡

6-­‑May-­‑13 ¡ 2 ¡

  • Bounding ¡Box ¡

– provided ¡

slide-3
SLIDE 3

Lecture 1 -

  • Philipp Krähenbühl

Goal ¡

6-­‑May-­‑13 ¡ 3 ¡

  • SegmentaFon ¡of ¡object ¡within ¡bounding ¡box ¡
slide-4
SLIDE 4

Lecture 1 -

  • Philipp Krähenbühl

Overview ¡

  • Boykov ¡& ¡Jolly ¡segmentaFon ¡model ¡

– SegmentaFon ¡using ¡Graph ¡Cuts ¡

  • GMM ¡foreground ¡and ¡background ¡model ¡

– IteraFve ¡opFmizaFon ¡

  • Graph ¡Cuts ¡
  • GMM ¡esFmaFon ¡

6-­‑May-­‑13 ¡ 4 ¡

E(α, z) = D(αn, zn)

n

+γ wn,m[αn ≠αm]

n,m

D(αn,θ, zn)

slide-5
SLIDE 5

Lecture 1 -

  • Philipp Krähenbühl

6-­‑May-­‑13 ¡ 5 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

Project ¡2 ¡ Not ¡required ¡ OpFonal ¡

slide-6
SLIDE 6

Lecture 1 -

  • Philipp Krähenbühl

NotaFon ¡

  • Trimaps ¡

– Sets ¡of ¡pixels ¡ – TB: ¡background ¡ – TF: ¡foreground ¡ – TU: ¡undecided ¡

  • SegmentaFon ¡

– αi ¡for ¡each ¡pixel ¡i ¡

6-­‑May-­‑13 ¡ 6 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

slide-7
SLIDE 7

Lecture 1 -

  • Philipp Krähenbühl

IniFalizaFon ¡

  • Outside ¡

– Background ¡(fixed) ¡ – αn=0 ¡

  • Inside ¡

– IniFal ¡foreground ¡ – αn=1 ¡ – updated ¡

6-­‑May-­‑13 ¡ 7 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

slide-8
SLIDE 8

Lecture 1 -

  • Philipp Krähenbühl

GMM ¡IniFalizaFon ¡

  • Find ¡parameters ¡θ ¡
  • Standard ¡method ¡

– random ¡+ ¡EM ¡

  • Re-­‑esFmate ¡θ ¡in ¡

step ¡2 ¡

– IniFalizaFon ¡only ¡ needed ¡for ¡step ¡1 ¡ – Trick: ¡IniFalize ¡k ¡ instead ¡

6-­‑May-­‑13 ¡ 8 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

slide-9
SLIDE 9

Lecture 1 -

  • Philipp Krähenbühl

GMM ¡IniFalizaFon ¡

  • Trick: ¡IniFalize ¡k ¡

– k-­‑means ¡clustering ¡ – skip ¡step ¡1 ¡in ¡first ¡ iteraFon ¡

6-­‑May-­‑13 ¡ 9 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

slide-10
SLIDE 10

Lecture 1 -

  • Philipp Krähenbühl

GMM ¡assignment ¡

  • Gaussian ¡log ¡prob. ¡
  • Enumerate ¡all ¡kn ¡
  • Each ¡pixel ¡already ¡

assigned ¡to ¡FG ¡or ¡ BG ¡(αn ¡fixed) ¡

6-­‑May-­‑13 ¡ 10 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

Dn(αn,kn,θ, zn) = −logπ(αn,kn)+ 1 2 logdet Σ(αn,kn) + 1 2 zn −µ(αn,kn)

[ ]

T Σ(αn,kn)−1 zn −µ(αn,kn)

[ ]

slide-11
SLIDE 11

Lecture 1 -

  • Philipp Krähenbühl

GMM ¡leaning ¡

  • Mixture ¡param. ¡
  • F(k) ¡set ¡of ¡FG ¡

pixels ¡assigned ¡to ¡

  • comp. ¡k ¡

6-­‑May-­‑13 ¡ 11 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

π(α =1,k) = F(k) F(k)

k

µ(α =1,k) = mean

n∈F(k)(zn)

Σ(α =1,k) = cov

n∈F(k)(zn)

slide-12
SLIDE 12

Lecture 1 -

  • Philipp Krähenbühl

SegmentaFon ¡

  • Find ¡segmentaFon ¡

that ¡minimizes ¡

– Reduces ¡to ¡Boykov ¡ & ¡Jolly ¡ – Solved ¡using ¡ GraphCut ¡

6-­‑May-­‑13 ¡ 12 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

min

k E(α,k,θ, z) =

min

kn D(αn,kn,θ, zn) D(αn,θ,zn )

     

n

+γ wn,m[αn ≠αm]

n,m

slide-13
SLIDE 13

Lecture 1 -

  • Philipp Krähenbühl

Use ¡energy.h ¡and ¡maxflow.cpp ¡

¡ // initialization std::vector<Energy::Var> vars(N); Energy e;

  • // add a node

vars[i] = e.add_variable();

  • // add the unary term for a node

e.add_term1(vars[i], u0, u1); // add the pairwise term for an edge e.add_term2(vars[i], vars[j], p00, p01, p10, p11);

  • // perform energy minimization

Energy::TotalValue mnE = e.minimize();

  • // get new labels

if (e.get_var(vars[i])) label[i] = 1; else label[i] = 0;

6-­‑May-­‑13 ¡ 13 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

min

k E(α,k,θ, z) =

D(αn,θ, zn)

n

+γ wn,m[αn ≠αm]

n,m

D(0,θ, zn) D(1,θ, zn)

slide-14
SLIDE 14

Lecture 1 -

  • Philipp Krähenbühl

Use ¡energy.h ¡and ¡maxflow.cpp ¡

¡ // initialization std::vector<Energy::Var> vars(N); Energy e;

  • // add a node

vars[i] = e.add_variable();

  • // add the unary term for a node

e.add_term1(vars[i], u0, u1); // add the pairwise term for an edge e.add_term2(vars[i], vars[j], p00, p01, p10, p11);

  • // perform energy minimization

Energy::TotalValue mnE = e.minimize();

  • // get new labels

if (e->get_var(vars[i])) label[i] = 1; else label[i] = 0;

6-­‑May-­‑13 ¡ 14 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

min

k E(α,k,θ, z) =

D(αn,θ, zn)

n

+γ wn,m[αn ≠αm]

n,m

? ¡ ? ¡ ? ¡ ? ¡

slide-15
SLIDE 15

Lecture 1 -

  • Philipp Krähenbühl

Use ¡energy.h ¡and ¡maxflow.cpp ¡

¡ // initialization std::vector<Energy::Var> vars(N); Energy e;

  • // add a node

vars[i] = e.add_variable();

  • // add the unary term for a node

e.add_term1(vars[i], u0, u1); // add the pairwise term for an edge e.add_term2(vars[i], vars[j], 0, vij, vij, 0);

  • // perform energy minimization

Energy::TotalValue mnE = e.minimize();

  • // get new labels

if (e->get_var(vars[i])) label[i] = 1; else label[i] = 0;

6-­‑May-­‑13 ¡ 15 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

min

k E(α,k,θ, z) =

D(αn,θ, zn)

n

+γ wn,m[αn ≠αm]

n,m

vij =γ exp(−β zi − zj

2)

slide-16
SLIDE 16

Lecture 1 -

  • Philipp Krähenbühl

6-­‑May-­‑13 ¡ 16 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

vij =γ exp(−β zi − zj

2)

slide-17
SLIDE 17

Lecture 1 -

  • Philipp Krähenbühl

6-­‑May-­‑13 ¡ 17 ¡

Initialisation

  • User initialises trimap T by supplying only TB. The fore-

ground is set to TF = / 0; TU = T B, complement of the back- ground.

  • Initialise αn = 0 for n ∈ TB and αn = 1 for n ∈ TU.
  • Background and foreground GMMs initialised from sets

αn = 0 and αn = 1 respectively. Iterative minimisation

  • 1. Assign GMM components to pixels: for each n in TU,

kn := argmin

kn

Dn(αn,kn,θ,zn).

  • 2. Learn GMM parameters from data z:

θ := argmin

θ U(α,k,θ,z)

  • 3. Estimate segmentation: use min cut to solve:

min

{αn: n∈T

U} min

k E(α,k,θ,z).

  • 4. Repeat from step 1, until convergence.
  • 5. Apply border matting (section 4).

User editing

  • Edit: fix some pixels either to αn = 0 (background brush)
  • r αn = 1 (foreground brush); update trimap T accord-
  • ingly. Perform step 3 above, just once.
  • Refine operation: [optional] perform entire iterative min-

imisation algorithm.

slide-18
SLIDE 18

Lecture 1 -

  • Philipp Krähenbühl

OpFmizaFons ¡

  • Use ¡MEX ¡files ¡for ¡Graph ¡Cut ¡

– Call ¡C/C++ ¡code ¡from ¡matlab ¡ – complile: ¡“mex ¡a.cpp ¡b.cpp ¡c.cpp ¡…” ¡

  • Vectorize ¡

– f: ¡Nx3 ¡matrix ¡of ¡RGB ¡color ¡values ¡ – a: ¡N-­‑dimensional ¡binary ¡vector ¡(segmentaFon) ¡ – f(a==1,:): ¡foreground ¡features ¡ – f(a==0,:): ¡background ¡features ¡

6-­‑May-­‑13 ¡ 18 ¡

slide-19
SLIDE 19

Lecture 1 -

  • Philipp Krähenbühl

ImplementaFon ¡QuesFons? ¡

6-­‑May-­‑13 ¡ 19 ¡

slide-20
SLIDE 20

Lecture 1 -

  • Philipp Krähenbühl

Extensions ¡

  • User ¡interacFon ¡or ¡border ¡manng ¡
  • Play ¡with ¡GMMs ¡

– Vary ¡number ¡of ¡components ¡ – Different ¡iniFalizaFon ¡ – Different ¡color ¡space ¡(Lab) ¡

  • Different ¡Color ¡model ¡

– Histogram ¡based ¡model ¡

6-­‑May-­‑13 ¡ 20 ¡

slide-21
SLIDE 21

Lecture 1 -

  • Philipp Krähenbühl

Extensions ¡

  • Different ¡Neighborhood ¡System ¡

– 4 ¡connected ¡ – 8 ¡connected ¡ – fully ¡connected ¡(DenseCRF) ¡

  • Efficient ¡Inference ¡in ¡Fully ¡Connected ¡CRFs ¡with ¡Gaussian ¡

Edge ¡PotenFals ¡[Krähenbühl ¡and ¡Koltun ¡2011] ¡

  • Different ¡“affinity” ¡

– Lab ¡color ¡difference ¡ – Contour ¡detector ¡gPb ¡

  • Contour ¡DetecFon ¡and ¡Hierarchical ¡Image ¡SegmentaFon ¡

[Arbelaez ¡etal ¡2010] ¡

6-­‑May-­‑13 ¡ 21 ¡

slide-22
SLIDE 22

Lecture 1 -

  • Philipp Krähenbühl

QuesFons? ¡

6-­‑May-­‑13 ¡ 22 ¡