image processing & computer vision

21
1 Image Processing & Computer Vision State space gradient descent & Gibbs sampler

Upload: kirby

Post on 11-Feb-2016

50 views

Category:

Documents


6 download

DESCRIPTION

Image Processing & Computer Vision. State space gradient descent & Gibbs sampler . Optimization (Finding best solution- หาวิธีที่ดีที่สุด). Hough Transform หาตำแหน่งของรูปทรงต่าง ๆ เช่น เส้นตรง, วงกลม, รูปทรงอื่น ๆ โดยการ voting (ให้คะแนน) State space gradient descent - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Image Processing & Computer Vision

1

Image Processing &Computer Vision

State space gradient descent &Gibbs sampler

Page 2: Image Processing & Computer Vision

2

Optimization (Finding best solution-หาวธทดทสด) Hough Transform

หาตำาแหนงของรปทรงตาง ๆ เชน เสนตรง, วงกลม, รปทรงอน ๆ โดยการ voting (ใหคะแนน)

State space gradient descent การแทนคาทเปนไปไดในแตละ state เพอทำาการหา Stable

Energy เพอเปนการตดสนวาเปนคาทดทสด Gibbs sampler

การแทนคาทเปนไปไดในแตละ state เพอทำาการหา Energy และ Probability Distribution Function (PDF) เพอเปนการตดสนวาเปนคาทดทสด

Page 3: Image Processing & Computer Vision

3

Computer vision problem Computing optical flow motion การคำานวณ

การเคลอนทของวตถโดยการหาคาเวกเตอร u และ v Stereo disparity depth คาความลกขององค

ประกอบหรอวตถตาง ๆ ภายในภาพ โดยใชภาพจำาลองของตาซายและตาขวา

Shape from Texture การหารปรางของวตถโดยดจากลวดลาย

Shape from Contour การหารปรางของวตถโดยดจากเสนแสดงขอบเขตของวตถ

Page 4: Image Processing & Computer Vision

4

State space gradient descent E = xy[(Fxy – Ixy)2 + (Fx+1,y – Fxy)2 + (Fx,y+1 – Fxy)2]

Algorithm

Initial F0(x,y) = Random 0….255

For each pixel x,yFor each possible state S

if F(x,y) = 0, E0 = …………

if F(x,y) = 1, E1 = …………

..............if F(x,y) = 255, E255 = ………..

Select state with minimum ELet’s F(x,y) = S

Repeat until no change in E

Noise 50% Restore

Page 5: Image Processing & Computer Vision

5

State space gradient descent

15 245 45 100 123

234 211 24 56 89

125 233 213 45 87

150 200 111 222 56

78 239 34 12 66

F(x,y) คอ คาทเปนไปได ทจะตองมการ update ในแตละรอบในรอบแรกจะทำาการ Random คาขนมากอน ซงคาทจะ Random มคาตงแต 0 - 255

E คอ Energy คอพลงงานทใชไปในแตละรอบ Ixy คอ Image Intensity ของภาพจรง คอ weightของเพอนบาน (Neighbor)

E = xy [(Fxy – Ixy)2 + (Fx+1,y – Fxy)2 + (Fx,y+1 – Fxy)2]

Data Constraint Smoothness Constraint

X,Y X+1,Y

X,Y+1

Page 6: Image Processing & Computer Vision

6

Energy (Global Energy)

การเปลยนคาทตำาแหนง x,y มผลกระทบตอคา Energyของ (x,y) (x-1,y) และ (x,y-1)

Clique คอ การเปลยนคาททำาใหเพอนบานทมองดตว x,y อย มผลกระทบดวย ดงนนการเปลยนคาในตำาแหนง x,y ใด ๆ นนจะตองมการคำานวณคา Energy ใหมดวยสตรดานลางน

Page 7: Image Processing & Computer Vision

7

Energy (Global Energy)

E = xy [(Fxy – Ixy)2 + (Fx+1,y – Fxy)2 + (Fx+1,y+1 – Fxy)2 + (Fx,y+1 – Fxy)2]

X,Y X+1,Y

X,Y+1 X+1,Y+1

กรณทดเพอนบาน 3 ตว คอ (x+1,y) (x+1,y+1) (x,y+1)

Page 8: Image Processing & Computer Vision

8

State space gradient descent

State space gradient descent เปนการหาคาทดทสดแบบ Greedyซงกคอการหาคาโดยทเมอเจอคาทคดวาดทสดเมอไหรกจะนำาเอาคานนมาเปนคำาตอบ ซงบางครงคาทไดอาจจะเปน Energy ท local minimum ซงไมใชคา ทเปนGlobal minimum ทแทจรงกได

Page 9: Image Processing & Computer Vision

9

Gradient descent Algorithm

1. Initial F0(x,y) = Random 0…2552. For each Pixel(x,y

For each state S = 0…255if F(x,y) = 0, E0 = …….

if F(x,y) = 1, E1 = …….……….

if F(x,y) = 255, E255 = …….

Choose state with minimum E F(x,y) = S3. Repeat step 2 until E is stable (not decrease)

Page 10: Image Processing & Computer Vision

10

Example (state space gradient)

15 245 45 100 123

234 211 24 56 89

125 233 213 45 87

150 200 111 222 56

78 239 34 12 66

5 6 7 2 5

10 200 7 8 205

8 7 5 4 2

11 11 5 7 210

5 7 0 2 3

0 1 2 3 4

0

1

2

3

4

0 1 2 3 4

0

1

2

3

4

F(x,y) I(x,y)

E = xy [(Fxy – Ixy)2 + (Fx+1,y – Fxy)2 + (Fx,y+1 – Fxy)2]

Data Constraint Smoothness Constraint

Page 11: Image Processing & Computer Vision

11

Gibbs Sampler เนองจาก state space gradient descent เปนวธ

แบบ Greedy ซงอาจจะทำาใหผลลพธทออกมาไมดเทาทควร

Gibbs Sampler คอ Algorithm อกแบบหนงซงนำาเขาชวยทำาใหวธการ state space gradient descent มผลลพธทดขนโดยหลกการทใชกคอ จะใชคา Probability Distribution Function รวมดวยในการตดสนใจหาผลลพธทดทสด

Page 12: Image Processing & Computer Vision

12

Gibbs Sampler1. Start temperature T is high2. Initial F0(x,y) = Random 0…2553. For each Pixel(x,y)

For each state S = 0…255if F(x,y) = 0; E0 = …..; P0 = …..;Prob0=….if F(x,y) = 1; E1 = …..; P1 = …..;Prob1=….…………………….if F(x,y) = 255; E255 = …..; P255 = …..;Prob255=For each Probi = Pi / sum(Pi)

4. Sample for state S from pdf Probi

F(x,y) = S5. Reduce T = T * 0.96. Repeat step 3-4 until E is stable

Page 13: Image Processing & Computer Vision

13

Gibbs Sampler จากคา E ทำาอยางไรจะไดคา Pi ออกมา จะทำาการหาคา Probability Distribution Function

(PDF) ไดอยางไร เพราะอะไรจงตองทำาการลดคา T (reduce T) และ T

มไวสำาหรบทำาอะไร

Page 14: Image Processing & Computer Vision

14

Gibbs Sampler สตรในการหาคา Pi

Pi = exp(-Ei/T) Z = sum(Pi)

Probi = Pi

Zเมอ

E = Energyexp = exponential มคาเทากบ 2.718 Z = ผลรวมทงหมดของ Pi

Page 15: Image Processing & Computer Vision

15

Gibbs Sampler ความหมายของคา T (Temperature)

(เดนแบบสม)

(เขาใกล 0 และเมอ Tมคานอยมากๆ นนหมายถงเขาสGradient Descent)

Probi = exp(-Ei/T)

Z

Page 16: Image Processing & Computer Vision

16

Gibbs Sampler การหาคา Probability Distribution Function (PDF)

ให Random คา probality ตงแต 0…1 แลวดวาคาท Random มานน ตกอยในชวงของ pdf ใด ใหทำาการเลอก state นนมา ดงตวอยาง

สมมตใหคาท Random = 0.43ดงนนจะได F(x,y) ตกอยใน state ท 3 คอ F(x,y) = 3

pdf

Page 17: Image Processing & Computer Vision

17

Gibbs Samplerตวอยาง 3 state 0,1,2

P1=exp(-3/T) P2=exp(-4/T)P0=exp(-2/T)

0.1

Page 18: Image Processing & Computer Vision

18

Example (gibbs sampler)

0 0 0 0 0

0 0 7 7 0

0 0 4 0 0

0 0 6 6 0

0 0 7 0 0

5 6 7 2 5

10 200 7 8 205

8 7 5 4 2

11 11 5 7 210

5 7 0 2 3

0 1 2 3 4

0

1

2

3

4

0 1 2 3 4

0

1

2

3

4

F(x,y) I(x,y)

E = xy [(Fxy – Ixy)2 + (Fx+1,y – Fxy)2 + (Fx,y+1 – Fxy)2]

Data Constraint Smoothness Constraint

Page 19: Image Processing & Computer Vision

19

Noise removal using Gibbs Sampler

ภาพจรงทไมม noise random noise50% ของภาพ

ภาพทไดจากการทำา Gibbssampler ภาพจะกลบคนมาไดดระดบหนง ซงทำาใหเหนรายละเอยดตาง ๆ ไดมากขน

Page 20: Image Processing & Computer Vision

20

Noise removal using Gibbs Sampler

E = xy [(Fxy – Ixy)2 + (Fx+1,y – Fxy)2 + (Fx,y+1 – Fxy)2]

Data Constraint Smoothness Constraint

เราจะใหคา มคาสงถาภายในภาพม noise เยอะ ซงกจะทำาให weight ของเพอนบาน(neighbor) มความสำาคญ (เชน 10,20)

คา จะมคาตำาถาภายในภาพม noise นอย ซงกจะทำาให weight ของเพอนบานไมมความสำาคญหรอมนอย ทำาให E มคาแปรผนตาม data จรง (เชน 0.001,0.0001)

หรอถาจะให weight ของทง data และ neighbor มคาเทากน จะ set ใหคา มคาเทากบ 1

Page 21: Image Processing & Computer Vision

21

Noise removal with missing data

E = xy [(Fxy – Ixy)2 Axy+ (Fx+1,y – Fxy)2 + (Fx,y+1 – Fxy)2]

Axy เปน 0 ถา no data เปน 1 ถา has data