# lens distortion - university of minnesotahspark/csci5980/lec2... · assumption: lens distortion is...

of 28 /28
Lens Distortion

Post on 13-Oct-2020

1 views

Category:

## Documents

TRANSCRIPT

Lens Distortion

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

udistorted

p px y,

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

udistorted

p px y,

Lu udistorted undistorted( )ρ

undistorted uρwhere

2 4 L k k1 2( ) 1ρ ρ ρ

uundistorted

Lu udistorted undistorted( )ρ

distorted uρwhere

2 4 L k k1 2( ) 1ρ ρ ρ

Lu udistorted undistorted( )ρ

2 4 L k k1 2( ) 1ρ ρ ρ

Lu udistorted undistorted( )ρ

distorted uρwhere

2 4 L k k1 2( ) 1ρ ρ ρ

2 4 L k k1 2( ) 1ρ ρ ρ

Lu udistorted undistorted( )ρ

01 k01 k

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

udistorted

p px y,

Lu udistorted undistorted( )ρ

undistorted uρwhere

2 4 L k k1 2( ) 1ρ ρ ρ

uundistorted

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

udistorted

p px y,

Lu udistorted undistorted( )ρ

where

2 4 L k k1 2( ) 1ρ ρ ρ

uundistorted

Normalized point:

u K u u K u-1 -1distorted distorted undistorted undistorted,

undistorted uρ

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

udistorted

p px y,

Lu udistorted undistorted( )ρ

where

2 4 L k k1 2( ) 1ρ ρ ρ

uundistorted

Normalized point:

u K u u K u-1 -1distorted distorted undistorted undistorted,

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

undistorted uρ

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

im = imread(‘image.jpg’); f = 1224; k = -0.08; px = size(im,2)/2; py = size(im,1)/2;

Distorted image

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

im = imread(‘image.jpg’); f = 1224; k = -0.08; px = size(im,2)/2; py = size(im,1)/2; im_new = zeros(size(im)); % create a new image for i = 1 : size(im,1) for j = 1 : size(im,2)

i,j

Undistorted image Distorted image

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

im = imread(‘image.jpg’); f = 1224; k = -0.08; px = size(im,2)/2; py = size(im,1)/2; im_new = zeros(size(im)); % create a new image for i = 1 : size(im,1) for j = 1 : size(im,2) dx = ([j;i]-[px;py])/f; r = norm(dx);

-1undistorted undistortedu K u

i,j

undistorted uρ

Undistorted image Distorted image

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

im = imread(‘image.jpg’); f = 1224; k = -0.08; px = size(im,2)/2; py = size(im,1)/2; im_new = zeros(size(im)); % create a new image for i = 1 : size(im,1) for j = 1 : size(im,2) dx = ([j;i]-[px;py])/f; r = norm(dx); l = 1 + k*r*r; x = f*l*dx+[cx;cy];

-1undistorted undistortedu K u

i,j

2 4 L k k1 2( ) 1ρ ρ ρ

distorted distortedKu u

Undistorted image Distorted image

undistorted uρ

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

im = imread(‘image.jpg’); f = 1224; k = -0.08; px = size(im,2)/2; py = size(im,1)/2; im_new = zeros(size(im)); % create a new image for i = 1 : size(im,1) for j = 1 : size(im,2) dx = ([j;i]-[px;py])/f; r = norm(dx); l = 1 + k*r*r; x = f*l*dx+[cx;cy]; if floor(x(1))<=0 || floor(x(1))>size(im,2) || floor(x(2))<=0 || floor(x(2))>size(im,1) continue; end im_new(i,j,:) = im(floor(x(2)), floor(x(1)),:); end end

-1undistorted undistortedu K u

i,j

2 4 L k k1 2( ) 1ρ ρ ρ

distorted distortedKu u

Undistorted image Distorted image

undistorted uρ

Radial Distortion Model Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

im = imread(‘image.jpg’); f = 1224; k = -0.08; px = size(im,2)/2; py = size(im,1)/2; im_new = zeros(size(im)); % create a new image for i = 1 : size(im,1) for j = 1 : size(im,2) dx = ([j;i]-[px;py])/f; r = norm(dx); l = 1 + k*r*r; x = f*l*dx+[cx;cy]; if floor(x(1))<=0 || floor(x(1))>size(im,2) || floor(x(2))<=0 || floor(x(2))>size(im,1) continue; end im_new(i,j,:) = im(floor(x(2)), floor(x(1)),:); end end

-1undistorted undistortedu K u

i,j

2 4 L k k1 2( ) 1ρ ρ ρ

distorted distortedKu u

Undistorted image Distorted image

undistorted uρ

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2);

X Y

XY coordinate

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f;

X Y

XY coordinate

-1undistorted undistortedu K u

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f; r_u = sqrt(X_n.^2+Y_n.^2);

X Y

XY coordinate

-1undistorted undistortedu K u

undistorted uρ

distorted uρ

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f; r_u = sqrt(X_n.^2+Y_n.^2); L = 1 + k * r_u.^2;

XY coordinate

-1undistorted undistortedu K u

2

1( ) 1 L kρ ρ

undistorted uρ

2

1( ) 1 L kρ ρ

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f; r_u = sqrt(X_n.^2+Y_n.^2); L = 1 + k * r_u.^2; X_dist_n = X_n.* L; Y_dist_n = Y_n.* L;

X Y

XY coordinate

-1undistorted undistortedu K u

2

1( ) 1 L kρ ρ

distorted distortedKu u

undistorted uρ

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f; r_u = sqrt(X_n.^2+Y_n.^2); L = 1 + k * r_u.^2; X_dist_n = X_n.* L; Y_dist_n = Y_n.* L;

Xdist Ydist

XY coordinate

-1undistorted undistortedu K u

2

1( ) 1 L kρ ρ

distorted distortedKu u

undistorted uρ

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f; r_u = sqrt(X_n.^2+Y_n.^2); L = 1 + k * r_u.^2; X_dist_n = X_n.* L; Y_dist_n = Y_n.* L; imUndistortion(:,:,1) = reshape(interp2(im(:,:,1), X_dist(:), Y_dist(:)), [h, w]); imUndistortion(:,:,2) = reshape(interp2(im(:,:,2), X_dist(:), Y_dist(:)), [h, w]); imUndistortion(:,:,3) = reshape(interp2(im(:,:,3), X_dist(:), Y_dist(:)), [h, w]);

XY coordinate

-1undistorted undistortedu K u

distorted uρ

2

1( ) 1 L kρ ρ

distorted distortedKu u

11a 12a

21a 22a

Bilinear interpolation

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

img

m

ccd

3840= = 0.00153 1224pix

0.0048

Wf f

W

img

x

3840= = 1920pix

2 2

Wp img

y

2160= = 1080pix

2 2

Hp

[[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X_n = (X-px)/f; Y_n = (Y-py)/f; r_u = sqrt(X_n.^2+Y_n.^2); L = 1 + k * r_u.^2; X_dist_n = X_n.* L; Y_dist_n = Y_n.* L; imUndistortion(:,:,1) = reshape(interp2(im(:,:,1), X_dist(:), Y_dist(:)), [h, w]); imUndistortion(:,:,2) = reshape(interp2(im(:,:,2), X_dist(:), Y_dist(:)), [h, w]); imUndistortion(:,:,3) = reshape(interp2(im(:,:,3), X_dist(:), Y_dist(:)), [h, w]);

XY coordinate

-1undistorted undistortedu K u

distorted uρ

2

1( ) 1 L kρ ρ

distorted distortedKu u

Bilinear interpolation

11a 12a

21a 22a

Radial Distortion Model (MATLAB Efficient) Assumption: Lens distortion is a function of distance from the principal point.

[X, Y] = meshgrid(1:(size(im,2)), 1:(size(im,1))); h = size(X, 1); w = size(X,2); X = X(:); Y = Y(:); pt = [X'; Y']; pt = bsxfun(@minus, pt, [px;py]); pt = bsxfun(@rdivide, pt, [f;f]); r_u = sqrt(sum(pt.^2, 1)); pt = bsxfun(@times, pt, 1 + k * r_u.^2); pt = bsxfun(@times, pt, [f;f]); pt = bsxfun(@plus, pt, [px;py]); imUndistortion(:,:,1) = reshape(interp2(im(:,:,1), pt(1,:), pt(2,:)), [h, w]); imUndistortion(:,:,2) = reshape(interp2(im(:,:,2), pt(1,:), pt(2,:)), [h, w]); imUndistortion(:,:,3) = reshape(interp2(im(:,:,3), pt(1,:), pt(2,:)), [h, w]);

-1undistorted undistortedu K u

distorted uρ

2 4 L k k1 2( ) 1ρ ρ ρ

distorted distortedKu u

Bilinear interpolation

i,j

Undistorted image Distorted image