Subjects/Computer Vision

[Camera model] Lens distortion

BiniU 2022. 3. 25. 12:06

Pinhole 카메라에서는 straight line은 straight line으로 투영된다. 

하지만 우리가 실제 사용하는 카메라는 pinhole 카메라와 다르게 렌즈를 통해 반사된 빛을 받는다.

 

따라서 우리가 사용하는 카메라는 렌즈에 의한 왜곡을 받게 된다.

왜곡은 straight line이 실제로 투영되었을 때 약간의 휘어짐을 갖는 채로 투영되게끔 한다.

 


 

Distortion types

일반적인 왜곡의 종류는 크게 두 가지로 나눌 수 있다. 

  • Radial distortion
  • Tangential distortion

 

<Radial distortion>

 

Radial distortion은 가장 일반적으로 나타나는 왜곡의 형태이다.

Radial distortion은 카메라 렌즈의 굴절률에 의해 발생하고, 그렇기 때문에 principal point과의 거리에 따라

왜곡의 정도가 심해지는 형태를 갖는다.

 

Radial distortion은 형태에 따라 또 몇 가지 형태로 분류된다. 

가장 일반적인 형태는 아래의 두 가지이다. 

  • Barrel distortion
  • Pincushion distortion

 

 

 

<Tangential distortion>

 

Tangential distortion이 발생하는 이유는 렌즈가 이미지 평면과 정확히 평행하지 않아서 생기는 왜곡이다. 

렌즈가 이미지 평면과 평행하지 않은 경우, 이미지는 기울어져서 보이게 된다.

 

 

 

 

Mathematic representation

렌즈 왜곡은 polynomial distortion model을 사용해서 나타낼 수 있다. 

이번 포스팅에서는 가장 일반적으로 쓰이는 model을 사용한다.

 

일반적으로 렌즈 왜곡의 수학적 모델은 카메라의 intrinsic parameter의 영향이 제거된

normalized image plane에서 정의된다.

더보기

Normalized image plane은 focal length의 거리가 1인 가상의 이미지 평면을 의미한다. 

 

<Modeling radial distortion>

Radial distortion을 나타내기 위해서는 일반적으로 $k_1,\ k_2,\ k_3$ 세 개의 parameter를 사용한다.

이 때, $x, y$는 undistorted pixel의 위치를 의미한다.

 

$$x_{distorted} = x(1 + k_1r^2 + k_2r^4 + k_3r^6 )$$

 

$$y_{distorted} = y(1 + k_1r^2 + k_2r^4 + k_3r^6 )$$

 

$$r^2 = x^2 + y^2$$

 

 

<Modeling tangential distortion>

tangential distortion을 나타내기 위해서는 일반적으로 $p_1,\ p_2$ 두 개의 parameter를 사용한다.

마찬가지로, $x, y$는 undistorted pixel의 위치를 의미한다.

 

$$x_{distorted} = x + [2p_1xy + p_2(r^2+2x^2)]$$

 

$$y_{distorted} = y + [p_1(r^2+2y^2) + 2p_2xy]$$

 

$$r^2 = x^2 + y^2$$

 

 

이렇게 왜곡을 결정하는 parameter는 아래와 같다는 것을 알 수 있다.

$$\therefore Distortion\ coefficients = (k_1\ k_2\ p_1\ p_2\ k_3)$$

 

 

Lens distortion correction

이번에는 왜곡된 영상에서 왜곡을 제거하는 프로세스를 알아볼 것이다. 

 

Lens distortion correction 작업은 distorted input image를 rectified(or undistorted) output image로

warping 하는 것을 의미한다.

 

아래 그림에서 왼쪽이 왜곡이 있는 입력 영상이고, 오른쪽 그림은 왜곡을 편 출력 영상이다. 

 

 

[Notation]

- Distorted input image 위 한 점의 pixel coordinate : $(u', v')$

- Distorted input image 위 한 점의 normalized image coordinate : $(x', y')$

- Undistorted output image 위 한 점의 pixel coordinate : $(u, v)$

- Undistorted output image 위 한 점의 normalized image coordinate : $(x, y)$

- Radial distortion coefficient: $k_1, k_2, k_3$

- Tangential distortion coefficient: $p_1, p_2$

- Undistorted output image 위 한 점의 pincipal point 까지의 거리 : $r$

 

1. Undistorted output image의 각 픽셀마다 해당 픽셀의 normalized image plane에서의 위치를 계산한다.

 

$$x = (u - c_x) / f_x$$

 

$$y = (v - c_y) / f_y$$

 

 

2. Distortion coefficient를 활용해서 $(x, y)$에 대응하는 $(x', y')$을 계산한다.

 

$$x' = x (1+k_1r^2 + k_2r^4 + k_3r^6) + 2p_1xy + p_2(r^2+2x^2)$$

 

$$y' = y (1+k_1r^2 + k_2r^4 + k_3r^6) + p_1(r^2+2y^2) + 2p_2xy$$

 

 

3. 구한 $(x', y')$를 pixel coordinate로 변환해서 $(u', v')$을 구한다.

 

$$u' = f_xx' + c_x$$

 

$$v' = f_yy' + c_y$$

 

 

4. $(u', v')$의 pixel 값을 $(u, v)$에 대입한다.

 

$$I(u, v) ← I(u', v')$$

 

 

 

 

반응형

'Subjects > Computer Vision' 카테고리의 다른 글

Euler angles  (0) 2022.06.24
[Camera model] Camera calibration  (0) 2022.03.31
[Camera model] Pinhole camera  (0) 2022.03.25
[Notations]  (0) 2022.03.23
[Geometric primitives] 2D points, 2D lines, 2D conics  (0) 2022.03.23