CS计算机代考程序代写 android [06-30213][06-30241][06-25024]

[06-30213][06-30241][06-25024]
Computer Vision and Imaging &
Robot Vision
Dr Hyung Jin Chang Dr Yixing Gao
h.j.chang@bham.ac.uk y.gao.8@bham.ac.uk
School of Computer Science

Today
– Fitting a 2D transformation • Homography
– 2D image warping
– Computing an image mosaic
SZELISKI (Chapter 9) – Image Stitching
• Image mosaics
2

HP frames commercial
• http://www.youtube.com/watch?v=2RPl5vPEoQk
3

Mosaics

Obtain a wider angle view by combining multiple images.
4
Slide credit: Kristen Grauman
image from S. Seitz

Panoramic Photos are old • Sydney, 1875
Beirut, late 1800’s Slide credit: James Hays

How to stitch together a panorama (a.k.a. mosaic)?
• BasicProcedure
– Take a sequence of images from the same position
– Compute transformation between second image and first – Transform the second image to overlap with the first
– Blend the two together to create a mosaic
– (If there are more images, repeat)
6 Source: Steve Seitz

Let’s Try!
• How to take a panorama with your iPhone or iPad
– Launch the Camera app on your iPhone or iPad.
– Swipe left twice to change modes to Pano.
– Tap the arrow button to change the capture direction, if desired. …
– Tap the shutter button to start taking a panoramic photo. • Android
– SelectPanoramicMode.LaunchthecameraonyourAndroid phone or tablet. Then tap the “MODE” button. …
– TakePanoramicShotwithAndroidCamera.Taptheshutterbutton.
– SaveandStorePanoramicShottoAndroidDevice.Taptheshutter again to end photographing.
7

Pinhole camera
• Pinholecameraisasimplemodeltoapproximate
imaging process, perspective projection.
Virtual image
pinhole
If we treat pinhole as a point, only one ray from any given point can enter the camera.
Slide credit: Kristen Grauman Fig from Forsyth and Ponce
Image plane
8

Mosaics: generating synthetic views
real camera
synthetic camera
Can generate any synthetic camera view
as long as it has the same center of projection!
Source: Alyosha Efros
9

Mosaics

Obtain a wider angle view by combining multiple images. 10
Slide credit: Kristen Grauman
image from S. Seitz

Image reprojection
The mosaic has a natural interpretation in 3D
• The images are reprojected onto a common plane
• The mosaic is formed on this plane
• Mosaic is a synthetic wide-angle camera
11
Source: Steve Seitz
mosaic Projective Plane (PP)

Image reprojection
Basic question
• How to relate two images from the same camera center? – howtomapapixelfromPP1toPP2
PP2
Answer
• Cast a ray through each pixel in PP1
• Draw the pixel where that ray intersects PP2
Observation:
Rather than thinking of this as a 3D reprojection, think of it as a 2D image warp from one image to another.
PP1
PP: Projection Plain
12
Source: Alyosha Efros

Image reprojection: Homography
A projective transform is a mapping between any two PPs with the same center of projection
• rectangle should map to arbitrary quadrilateral
• parallel lines aren’t preserved
• but must preserve straight lines
called Homography
PP2
éwx’ù * * * éxù êúéùêú
PP1
êwy’ú = ê* * *úêyú w ê***ú1
ëûëûëû
p’ H p
13
Source: Alyosha Efros

The projective plane
Why do we need homogeneous coordinates?
• represent points at infinity, homographies, perspective projection, multi-view relationships
What is the geometric intuition?

a point in the image is a ray in projective space
-y
(0,0,0)
x
(sx,sy,s)
(x,y,1)
-z
image plane

– all points on the ray are equivalent: (x, y, 1) ≅(sx, sy, s)
Each point (x,y) on the plane is represented by a ray (sx,sy,s)

(x , y ) 11
(x2,y2) (x , y )
(x¢,y¢) 11
(x¢,y¢) 22
(x¢,y¢) nn
Homography
nn
To compute the homography given pairs of corresponding points in the images, we need to set up an equation where the parameters of H are the unknowns…
Slide credit: Kristen Grauman
15

Solving for homographies
p’ = Hp
éwx’ù éh00 h01
êwy’ú=êh10 h11
ê w ú êh20 h21
ëûë ûëû
h02ùéxù h12úêyú h22úê1ú
Upto a scale factor.
Constraint Frobenius norm of H to be 1.
Problem to be solved:
min Ah-b 2
s.t.
where vector of unknowns h = [h00,h01,h02,h10,h11,h12,h20,h21,h22]T
h2 =1
16

Solving for homographies
éwxi’ù éh00
êwyi’ú=êh10
ê w ú êh20
ëûë ûëû
h01 h02ùéxiù h11 h12úêyiú h21 h22úê1ú

Solving for homographies
Ah0 2n × 9 9 2n
Defines a least squares problem:
• Since h is only defined up to scale, solve for unit vector ĥ (i.e., h 2 = 1)
• Solution: ĥ = eigenvector of ATA with smallest eigenvalue
• Works with 4 or more points

(x,y)
æwx¢ wy¢ ö çè w , w ÷ø
¢¢ = (x , y )
Homography
To apply a given homography H
• Compute p’ = Hp (regular matrix multiply)
• Convert p’ from homogeneous to image coordinates
éùé ùéù
Slide credit: Kristen Grauman
p’ H p
19
wx’ ***x êwy’ú = ê* * *úêyú
ê ú ê***úêú ëwû ë ûë1û

Today
– Fitting a 2D transformation • Homography
– 2D image warping
– Computing an image mosaic
• Image mosaics
20

Image warping
T(x,y) y y’
x f(x,y) x’ g(x’,y’)
Given a coordinate transform and a source image f(x,y), how do we compute a transformed image g(x’,y’) = T(f(x,y))?
Slide from Alyosha Efros
21

Forward warping
T(x,y)
y y’
x f(x,y) x’ g(x’,y’) Send each pixel f(x,y) to its corresponding location
(x’,y’) = T(x,y) in the second image Q: what if pixel lands “between” two pixels?
Slide from Alyosha Efros
22

Forward warping
T(x,y)
y y’
x f(x,y) x’ g(x’,y’) Send each pixel f(x,y) to its corresponding location
(x’,y’) = T(x,y) in the second image Q: what if pixel lands “between” two pixels?
A: distribute color among neighboring pixels (x’,y’)
– Known as “splatting” Slide from Alyosha Efros
23

Inverse warping
T-1(x,y) y y’
x f(x,y) x’ g(x’,y’)
Get each pixel g(x’,y’) from its corresponding location
(x,y) = T-1(x’,y’) in the first image
Q: what if pixel comes from “between” two pixels?
Slide from Alyosha Efros
24

Inverse warping
T-1(x,y) y y’
x f(x,y) x’ g(x’,y’)
Get each pixel g(x’,y’) from its corresponding location
(x,y) = T-1(x’,y’) in the first image
Q: what if pixel comes from “between” two pixels?
A: Interpolate color value from neighbors
– nearestneighbor,bilinear… Slide from Alyosha Efros
>> help interp2
25

Bilinear interpolation Sampling at f(x,y):
A geometric visualisation of bilinear interpolation. The product of the value at the desired point (black) and the entire area is equal to the sum of the products of the value at each corner and the partial area diagonally opposite the corner (corresponding colours)
Slide from Alyosha Efros
26

Recap: How to stitch together a panorama (a.k.a. mosaic)?
• BasicProcedure
– Take a sequence of images from the same position
– Compute transformation (homography) between second image and first using corresponding points.
– Transform the second image to overlap with the first.
– Blend the two together to create a mosaic.
– (If there are more images, repeat)
27 Source: Steve Seitz

Image warping with homographies
image plane in front
image plane below
black area where no pixel maps to
28
Source: Steve Seitz

Image rectification
Slide credit: Kristen Grauman
p
p’
29

Analysing patterns and shapes
What is the shape of the b/w floor pattern?
The floor (enlarged)
Slide from Antonio Criminisi
Automatically rectified floor
30
Homography

Analysing patterns and shapes
Slide from Antonio Criminisi
From Martin Kemp The Science of Art (manual reconstruction)
31
Automatic rectification

Analysing patterns and shapes
St. Lucy Altarpiece, D. Veneziano
32
Slide from Criminisi
What is the (complicated) shape of the floor pattern?
Automatically rectified floor

Analysing patterns and shapes
Slide from Criminisi
From Martin Kemp, The Science of Art (manual reconstruction)
Automatic rectification
33

Julian Beever: Manual Homographies
http://users.skynet.be/J.Beever/pave.htm

Changing camera center Does it still work?
PP1
synthetic PP
PP2
Source: Alyosha Efros
35

Recall: same camera center
real camera
synthetic camera
Can generate synthetic camera view
as long as it has the same center of projection.
Source: Alyosha Efros
36

…Or: Planar scene (or far away)
PP1
PP3 is a projection plane of both centers of projection, so we are OK!
This is how big aerial photographs are made
37
PP3
PP2
Source: Alyosha Efros

38

RANSAC for estimating
homography
• RANSAC loop:
• 1. Select four feature pairs (at random)
• 2. Compute homography H (exact)
• 3. Compute inliers where SSD(pi’, Hpi)< ε • 4. Keep largest set of inliers • 5. Re-compute least-squares H estimate on all of the inliers 39 Slide credit: Steve Seitz Robust feature-based alignment 40 Source: L. Lazebnik Robust feature-based alignment • Extract features 41 Source: L. Lazebnik Robust feature-based alignment • Extract features • Compute putative matches 42 Source: L. Lazebnik Robust feature-based alignment • Extract features • Compute putative matches • Loop: – Hypothesize transformation T (small group of putative matches that are related by T) 43 Source: L. Lazebnik Robust feature-based alignment • Extract features • Compute putative matches • Loop: – Hypothesize transformation T (small group of putative matches that are related by T) – Verify transformation (search for other 44 matches consistent with T) Source: L. Lazebnik Robust feature-based alignment • Extract features • Compute putative matches • Loop: – Hypothesize transformation T (small group of putative matches that are related by T) – Verify transformation (search for other 45 matches consistent with T) Source: L. Lazebnik Summary: alignment & warping • Write 2D transformations as matrix-vector multiplication (including translation when we use homogeneous coordinates) • Fitting transformations: solve for unknown parameters given corresponding points from two views (affine, projective (homography)). • Perform image warping (inverse) • Mosaics: uses homography and image warping to merge views taken from same center of projection. Slide credit: Kristen Grauman 46 Thank you Hyung Jin Chang 28/02/2021