introduction to computer graphics image...

38
Introduction to Computer Graphics – Image Processing (1) – June 8, 2017 Kenshi Takayama

Upload: others

Post on 12-Jul-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Introduction to Computer Graphics

– Image Processing (1) –

June 8, 2017

Kenshi Takayama

Page 2: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Today’s topics

• Edge-aware image processing

• Gradient-domain image processing

2

Page 3: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Image smoothing using Gaussian Filter

• Smoothness parameter 𝜎

3

𝜎 = 2 𝜎 = 5 𝜎 = 10Original

Page 4: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Equation of Gaussian Filter

• 𝐼𝐩 represents pixel value of image 𝐼 at position 𝐩 = 𝑝x, 𝑝y ∈ Ω• For given resolution e.g. 640×480, Ω ≔ 1,⋯ , 640 × 1,⋯ , 480

• GF𝜎[𝐼] represents filtered image with Gaussian parameter 𝜎 :

• 𝐺𝜎 𝑥 ≔ exp −𝑥2

2𝜎2 Gaussian Kernel of radius 𝜎

4

0𝑥

−𝜎−2𝜎−3𝜎 3𝜎2𝜎𝜎

𝐺𝜎 𝑥

GF𝜎 𝐼 𝐩 ≔σ𝐪∈Ω𝐺𝜎 𝐩 − 𝐪 𝐼𝐪

σ𝐪∈Ω𝐺𝜎 𝐩 − 𝐪

𝑊𝐩

Page 5: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Equation of Gaussian Filter

• 𝐼𝐩 represents pixel value of image 𝐼 at position 𝐩 = 𝑝x, 𝑝y ∈ Ω• For given resolution e.g. 640×480, Ω ≔ 1,⋯ , 640 × 1,⋯ , 480

• GF𝜎[𝐼] represents filtered image with Gaussian parameter 𝜎 :

• 𝐺𝜎 𝑥 ≔ exp −𝑥2

2𝜎2 Gaussian Kernel of radius 𝜎

5

0𝑥

−𝜎−2𝜎−3𝜎 3𝜎2𝜎𝜎

𝐺𝜎 𝑥

GF𝜎 𝐼 𝐩 ≔1

𝑊𝐩

𝐪∈Ω

𝐺𝜎 𝐩 − 𝐪 𝐼𝐪

Page 6: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Implementing Gaussian Filter

• 𝐺𝜎 3𝜎 ≈ 0 Distant pixels can be ignored

• For fixed size 𝑟 ≔ ceil 3𝜎 , precompute weights on a (2𝑟 + 1) × (2𝑟 + 1) stencil

6

0𝑥

−𝜎−2𝜎−3𝜎 3𝜎2𝜎𝜎

𝐺𝜎 𝑥

http://people.csail.mit.edu/sparis/bf_course/

2𝑟 + 1

2𝑟+1

Stencil

Page 7: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

When kernel radius 𝜎 is very large

• Direct computation takes a lot of time

• Alternative: downsample smooth with small 𝜎 upsample

7

𝜎 = 20

𝜎 = 5downsample upsample

Page 8: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Detail Extraction & Enhancement

8

3 ×

smoothed detail

enhanceddetail

halos!

Page 9: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

When using edge-aware smoothing, ...

9

3 ×

smoothed detail

enhanceddetail

Page 10: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Edge-aware smoothing using Bilateral Filter

• Two parameters• 𝜎s : Range of smoothing w.r.t. pixel’s location

• 𝜎r : Range of smoothing w.r.t. pixel’s color

BF𝜎s, 𝜎r 𝐼 𝐩 ≔1

𝑊𝐩

𝐪∈Ω

𝐺𝜎s 𝐩 − 𝐪 𝐺𝜎r 𝐼𝐩 − 𝐼𝐪 𝐼𝐪

10𝜎r = 32 𝜎r = 128 𝜎r = 512Original

In all cases, 𝜎s = 10

Page 11: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Application of Bilateral Filter: Stylization

11Real-time video abstraction [Winnemöller SIGGRAPH06]

(Draw silhouette lines over filtered image)

Page 12: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Application of Bilateral Filter: Tone Mapping

• Range of each channel (24bit color image): 1~255

• Range of light intensity in the real world: 1~105

• High Dynamic Range image

• Can be obtained by photographing with different exposure times

12https://en.wikipedia.org/wiki/Tone_mapping

Original captured image

(Without tone mapping)

Tone mapped image

Page 13: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Application of Bilateral Filter: Tone Mapping

13

γ correct. (𝑋 → 𝑋𝛾)

details lost

HDR image

Bilateral Filter

details preservedFast bilateral filtering for the display of high-dynamic-range images [Durand SIGGRAPH02]

Page 14: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Naïve implementation of Bilateral Filter

1

𝑊𝐩

𝐪∈Ω

𝐺𝜎s 𝐩 − 𝐪 𝐺𝜎r 𝐼𝐩 − 𝐼𝐪 𝐼𝐪

• Recompute stencil for every pixel location 𝐩 ∈ Ω slow

• (Basic Assignment)

14

Page 15: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Another view toward Bilateral Filter

• Define feature vector 𝐟𝐩 ≔𝐩

𝜎s,𝐼𝐩

𝜎rfor pixel location 𝐩 and intensity 𝐼𝐩

• Weight of Bilateral Filter is equivalent to

Gaussian kernel applied to Euclidean distance

in the feature space

• Bilateral Filter is equivalent to applying Gaussian Filter of radius 1

to sample points {𝐟𝐩} in the feature space

Simpler computation15

𝐺𝜎s 𝐩 − 𝐪 𝐺𝜎r 𝐼𝐩 − 𝐼𝐪

= exp −𝐩 − 𝐪 2

2𝜎s2 exp −

𝐼𝐩 − 𝐼𝐪2

2𝜎r2

= exp −𝐟𝐩 − 𝐟𝐪

2

2

= 𝐺1 𝐟𝐩 − 𝐟𝐪

Page 16: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Bilateral Grid [Paris06; Chen07]

• Define 3D feature space as (X-coord, Y-coord, intensity),

map sample points {𝐟𝐩} to 3D grid

• The larger 𝜎s & 𝜎r, the coarser the grid lower comput. cost

16A Fast Approximation of the Bilateral Filter using a Signal Processing Approach [Paris ECCV06]

Real-time edge-aware image processing with the bilateral grid [Chen SIGGRAPH07]

Page 17: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Weight map generation using feature space

• Various names: Edit Propagation, Matting, Segmentation

• Solve Laplace equationon Bilateral Grid

17

White scribble constraint of weight=1

Black scribble constraint of weight=0

Weight map Application: color adjustment

Real-time edge-aware image processing with the bilateral grid [Chen SIGGRAPH07]

Page 18: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Weight map generation using feature space

18Instant Propagation of Sparse Edits on Images and Videos [Li PG10]

Bilateral Hermite Radial Basis Functions for Contour-based Volume Segmentation [Ijiri EG13]

https://www.youtube.com/watch?v=mL6ig_OaQAA

Interpolation using RBF [Li10]

(Purpose: edit propagation for images/videos)

Interpolation using Hermite RBF [Ijiri13]

(Purpose: segmentation of CT volume)

Page 19: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Extension of Bilateral Filter: Joint (Cross) Bilateral Filter

19Digital Photography with Flash and No-Flash Image Pairs [Petschnigg SIGGRAPH04]

Flash Photography Enhancement via Intrinsic Relighting [Eisemann SIGGRAPH04]

Photo A: without flash

Correct color

Noisy, blurred

Photo F: with flash

Incorrect color

Less noisy, sharp

JBF𝜎s, 𝜎r 𝐴, 𝐹 𝐩 ≔1

𝑊𝐩

𝐪∈Ω

𝐺𝜎s 𝐩 − 𝐪 𝐺𝜎r 𝐹𝐩 − 𝐹𝐪 𝐴𝐪

After applying JBF

Basic idea:

- Get color information from A

- Get structure information from F

Page 20: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Extension of Bilateral Filter: Non-Local Means Filter

• Define feature space by neighborhood vector 𝐧𝐩representing 7×7 sub-image centered at 𝐩

20A non local algorithm for image denoising [Buades CVPR05]

NLMF𝜎 𝐼 𝐩 ≔1

𝑊𝐩

𝐪∈Ω

𝐺𝜎 𝐧𝐩 − 𝐧𝐪 𝐼𝐪

Noisy input Bilateral NL Means

Page 21: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Today’s topics

• Edge-aware image processing

• Gradient-domain image processing

21

Page 22: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Scenario: insert source img. into destination img.

22Poisson image editing [Perez SIGGRAPH03]

Gradient Domain Manipulation Techniques in Vision and Graphics [Agrawal ICCV07 Course]

Simple copying

Boundary blurred

Gradient-domain processing

Source Dest.

Page 23: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Scenario: generating panorama from several shots

23Efficient gradient-domain compositing using quadtrees [Agarwala SIGGRAPH07]

Simple tiling

Gradient-domain processing

Page 24: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Simple case of 1D grayscale image

24

Offset

Dest.Source

Page 25: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

2D case: offset by Laplace Membrane

25Mean value coordinates [Floater CAGD03]

Coordinates for instant image cloning [Farbman SIGGRAPH09]

• Solve Laplace equation underDirichlet boundary condition

• Fast approximation usingMean Value Coordinates

https://www.youtube.com/watch?v=AXvPeuc-wRw

Page 26: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Gradient-domain processing in general form(not just simple cloning)

26

Page 27: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

27

×20||

Modify gradients arbitrarily!

Gradient-domain processing in general form(not just simple cloning)

Page 28: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

28

𝑓∗𝑔𝑖

𝑓∗

Find 𝑓𝑖 that minimize

𝑖

𝑓𝑖 − 𝑓𝑖−1 − 𝑔𝑖2

subject to: 𝑓ȁ𝜕Ω = 𝑓∗ȁ𝜕Ω

Ω

Find function 𝑓 such that its

gradient closely matches

user-specified target 𝑔𝑖

Gradient-domain processing in general form(not just simple cloning)

Page 29: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

• Basics of Gradient-domain image processing:

Find image 𝑓 whose gradient best matches user-specified target gradient field 𝐠by solving Poisson equation

29

Find 𝑓𝑖 that minimize

𝑖

𝑓𝑖 − 𝑓𝑖−1 − 𝑔𝑖2

subject to: 𝑓ȁ𝜕Ω = 𝑓∗ȁ𝜕Ω

Find 𝑓 𝑥, 𝑦 that minimizes

න𝑥,𝑦 ∈Ω

𝛁𝑓 𝑥, 𝑦 − 𝐠(𝑥, 𝑦) 2

subject to: 𝑓ȁ𝜕Ω = 𝑓∗ȁ𝜕Ω

1D case 2D case

Solve Poisson equation:

Δ𝑓 = 𝛁 ⋅ 𝐠

subject to: 𝑓ȁ𝜕Ω = 𝑓∗ȁ𝜕Ω

Page 30: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

How to give target gradients: mixing

• Copy source’s gradient only when its magnitude is larger

smooth part of source won’t be copied

30Poisson image editing [Perez SIGGRAPH03]

Source Destination Always use

source gradient

Use source or dest. gradient

with greater magnitude

Page 31: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

How to give target gradients: mixing

• Copy source’s gradient only when its magnitude is larger

smooth part of source won’t be copied

31Poisson image editing [Perez SIGGRAPH03]

Source Destination Always use

source gradient

Use source or dest. gradient

with greater magnitude

Page 32: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

How to give target gradients: mixing

• Copy source’s gradient only when its magnitude is larger

smooth part of source won’t be copied

32Poisson image editing [Perez SIGGRAPH03]

source

dest.

source

dest.

source

dest.

Page 33: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

How to give target gradient: Edge Brush

• Copy gradients along object silhouette,paste along brush stroke

• Real-time Poisson solver implemented on GPU

33Real-time gradient-domain painting [McCann SIGGRAPH08]

Code: http://graphics.cs.cmu.edu/projects/gradient-paint/gradient_paint.r2403.tar.gz

https://www.youtube.com/watch?v=9MGjrsPzFc4

Before After Before After

Page 34: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

How to give target gradient: modify original

34Poisson image editing [Perez SIGGRAPH03]

Amplify/suppress within selected region

Local Tone Mapping

Set to zero except where detected as edges

Stylization

Page 35: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Extra:Gradient-domain geometry processing

35

Page 36: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Gradient-domain geometry processing

36

Find 𝐯𝑖 that minimize

𝑖,𝑗 ∈𝐸

𝑤𝑖𝑗 𝐯𝑖 − 𝐯𝑗 − 𝐞𝑖𝑗2

subject to: 𝐯𝑐 = 𝐯𝑐∗, 𝑐 ∈ 𝐼𝐶

Mesh editing with poisson-based gradient field manipulation [Yu SIGGRAPH04]

Laplacian surface editing [Sorkine SGP04]

Interfaces and algorithms for the creation, modification, and optimization of surface meshes [Nealen PhD07]

Edge vector of original shape

target gradient

A few constraints of vertex positions

boundary condition

Poisson equation

Page 37: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

Rotation of local region due to large deformation

• Target gradient needs to be rotated as well

• Non-linear relation

• Optimal rotation difficult to find

• Local-global optimization [Sorkine07]

• Local step:

Fix vertex positions,

compute local rotation using SVD

• Global step:

Fix local rotations,

compute vertex positions via Poisson equation

37On linear variational surface deformation methods [Botsch TVCG08]

As-rigid-as-possible surface modeling [Sorkine SGP07]

https://www.youtube.com/watch?v=ltX-qUjbkdc

Without rotation With rotation

Page 38: Introduction to Computer Graphics Image …research.nii.ac.jp/~takayama/teaching/utokyo-iscg-2017/...Fix vertex positions, compute local rotation using SVD •Global step: Fix local

GeoBrush:Cloning brush for surface meshes

• Split deformation into two steps:

1. Rotation of local region Fast & approx. computation using

cage-based method

2. Accurate offset Adapt GPU-based Poisson solver

(originally for image processing)

38GeoBrush: Interactive Mesh Geometry Cloning [Takayama EG11]

https://www.youtube.com/watch?v=FPsccn_gG8E