[선형대수] Lecture 31: Change of basis; image compression

이재호·2025년 3월 28일

선형대수

목록 보기
30/31

https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/video_galleries/video-lectures/

해당 강의에서는 다음과 같은 내용을 배운다.

  • change of basis
  • compression of images
  • Transformation <-> Matrix

먼저 이미지를 생각해보자. 일반적으로 이미지는 여러 개의 pixel로 이루어져있다.
예를 들어, 이미지 크기가 512 x 512 라고 가정하면, 해당 이미지 벡터의 차원은 R5122\R^{512^2} 을 가질 것이다.
이렇게 되면 크기가 매우 커진다. 따라서 Compression 을 적용하여야 한다. (ex. JPEG )

basis 에 대해서 좀더 생각해보자.

Standard Basis\text{Standard Basis}
[100],[0100],...,[0001]\begin{bmatrix} 1 \\ 0 \\ | \\ | \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \\ 0 \\ | \\ 0 \end{bmatrix}, ... , \begin{bmatrix} 0 \\ 0 \\ 0 \\ | \\ 1 \end{bmatrix}

위는 standard basis 의 예시이다. 이러한 basis 로 이미지를 표현하면 비효율적일 것이다. (ex. 5122512^2 차원 -> 5122512^2 개의 standard basis)

다음은 better basis 의 예시이다.

Better Basis\text{Better Basis}
[111],[1111],[111111]\begin{bmatrix} 1 \\ 1 \\ | \\ | \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ | \\ 1 \\ -1 \\ | \\ -1 \end{bmatrix}, \begin{bmatrix} 1 \\ -1 \\ 1 \\ -1 \\ 1 \\ -1 \end{bmatrix}

위에서 [1111]\begin{bmatrix} 1 \\ | \\ 1 \\ -1 \\ | \\ -1 \end{bmatrix} 는 절반/절반 으로 구분되는 이미지를 표현할 수 있고,
[111111]\begin{bmatrix} 1 \\ -1 \\ 1 \\ -1 \\ 1 \\ -1 \end{bmatrix} 는 체크무늬로 표현할 수 있을 것이다.

다음은 Fourier basis 의 예시이다. (8 x 8)

[11111111],[1ww2wn1],...\begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ w \\ w^2 \\ | \\ | \\ | \\ | \\ w^{n-1} \end{bmatrix}, ...

빠르게 basis 를 구할 수 있다는 장점이 있다.


즉, Compression of Image 에서 필요한 절차는 다음과 같다.

Signal xchange(lossless)coeffs ccompression(lossy)c^ (many zeros)Signal~x \underbrace{\to}_{change(lossless)} coeffs~c \underbrace{\to}_{compression(lossy)} \hat c~(many~zeros)
x^=c^ivi\hat x=\sum \hat c_i v_i

그리고 video 의 경우,
비디오는 sequence of images 이므로, 이미지 간 correlated 한 성질을 이용할 수 있다.


다음은 wavelets basis 의 예시이다. (R8\in\R^8)

[11111111],[11111111],[11110000],[00001111],[11000000],...\begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \\ -1 \\ -1 \\ -1 \\ -1 \end{bmatrix}, \begin{bmatrix} 1 \\ 1 \\ -1 \\ -1 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 1 \\ 1 \\ -1 \\ -1 \end{bmatrix}, \begin{bmatrix} 1 \\ -1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}, ...

보다시피 orthogonal basis 라는 것을 알 수가 있다.
그리고 각 픽셀은 다음과 같이 계산된다.

p=c1w1+...+c8w8p=c_1w_1+...+c_8w_8
p=[11...11...11...11...11...11...11...11...][c1c2.....c8]p=\begin{bmatrix} 1 & 1 & ... \\ 1 & 1 & ... \\ 1 & 1 & ... \\ 1 & 1 & ... \\ 1 & -1 & ... \\ 1 & -1 & ... \\ 1 & -1 & ... \\ 1 & -1 & ... \end{bmatrix} \begin{bmatrix} c_1 \\ c_2 \\ . \\ . \\ . \\ . \\ . \\ c_8 \end{bmatrix}
p=Wcp=Wc
c=W1pc=W^{-1}p

위 수식에서 coefficients c 를 구할 수도 있다.


다음은 good basis 의 조건이다.

  • Fast. (ex. FFT (Fast-Fourier-Transform), FWT (Fast-Wavelets-Transform) )
  • Few is enough. (적은 수의 basis 로도 표현이 가능해야 함.)

따라서 Change of Basis 는 다음과 같다.

위에서 WW의 칼럼들은 새로운 basis vectors 를 의미하는 것을 알았다.
그리고 다음과 같이 x old basisc new basisx\text{ old basis}\to c\text{ new basis} 를 통해 change of basis 개념을 알았다.

x=Wcx=Wc

이제 Transformation <-> Matrix 를 알아보자.
우선 다음을 보자.

about T,\text{about}~T,
with respect to v1,...,v8 it has matrix A\text{with respect to $v_1,...,v_8$ it has matrix $A$}
with respect to w1,...,w8 it has matrix B\text{with respect to $w_1,...,w_8$ it has matrix $B$}

위에서 AABB의 관계는 어떻게 정의할 수 있을까? 이 경우 AABB는 similar 하다고 볼 수 있다.

B=M1AMB=M^{-1}AM

위에서 MMchange of basis matrix\text{change of basis matrix} 를 의미한다.

그렇다면 어떻게 AA 를 구할 수 있을까? (지난 강의에서 배운 내용)

x=c1v1+...+c8v8x=c_1v_1+...+c_8v_8
T(x)=c1T(v1)+...+c8T(v8)T(x)=c_1T(v_1)+...+c_8T(v_8)
T(v1)=a11v1+a21v2+...+a81v8T(v_1)=a_{11}v_1+a_{21}v_2+...+a_{81}v_8
T(v2)=a12v1+a22v2+...+a82v8T(v_2)=a_{12}v_1+a_{22}v_2+...+a_{82}v_8
......
[A]=[a11a21...a18a28][A]= \begin{bmatrix} a_{11} & a_{21} & \\ | & | & ...\\ a_{18} & a_{28} & \\ \end{bmatrix}

그렇다면 만약 vv 가 eigenvector basis 라면 어떨까.
다음과 같다.

T(vi)=λiviT(v_i)=\lambda_i v_i
A=[λ100λ2...00]A= \begin{bmatrix} \lambda_1 & 0 & \\ 0 & \lambda_2 & \\ | & | & ...\\ 0 & 0 & \\ \end{bmatrix}
profile
천천히, 그리고 꾸준히.

0개의 댓글