그래픽스

가우시안 블러 (Separable Gaussian blur)

mumu3997 2024. 2. 2. 15:41

Separable Gaussian blur에 대해 알아보자.

 

블러라 하면 뭘까? 블러(blur)는 흐릿해지다라는 뜻으로, 사진에서의 블러효과라고 하면 흐릿해지는 효과라고 우리는 알고있다.

 

단순히 포토샵으로 블러효과를 적용하는게 아닌 이론적으로 어떻게 블러 효과를 만들어 내는지에 대해 알아보았다.

 

블러 효과를 만드는 간단한 과정은 원본 이미지와 커널 사이에 Convolution을 적용하여 블러 효과를 얻는것이다.

 

커널을 이미지에 쭉 적용시키는것을 Convolution이라고 한다.

컨벌루젼에 대해 설명하는 그림
Convolution  과정

 

제목을 보면 알겠지만 Separable Gaussian blur를 알아가는게 목적이다.

 

Separable은 왜 붙었을까?

 

커널 작업을 여러 단계로 나누었기 때문에 Separable이라는 단어가 붙은것이다!

 

Separable Convolution

 

Separable Convolutions

2D Convolution 대신 1D Convolution 을 두번 하는것이다.

 

기존 커널이 3x3이면 매개변수는 9개이지만, 1x3, 3x1 두개는 매개변수가 6개이다. 따라서 더 적은 매개변수로 더 적은 연산을 통해 같은 결과를 얻어낼 수 있는것이다.

 

하지만 치명적인 단점이 있다. 바로 분리 할 수없는 커널이 존재하는 경우이다. 이런 경우엔 Pointwise Convolution, Depthwise convolution등 다른 방법들이 있지만, 추후에 따로 정리해야겠다. 

 

이제 Speratable까지는 이해를 했다. Gaussian blur 는 그럼 뭘까?

 

Gaussian blur(Gaussian filter)

위 사진의 커널을 보자. 위와 같은 커널로 Convolution을 하면 결과는 어떻게 될까?

 

정답은 그냥 원본과 같다. 위 사진의 Image result는 원본 사진이다.

Box blur & Gaussian blur

가우시안 블러는 위 사진을 보면 알겠지만, 가까운쪽에 더 많은 가중치를 준다.

 

1차원의 가우스 함수

 

2차원의 가우스 함수
2차원의 가우스함수

가우스 함수의 값은 표준편차를 나타낸다.

표준편차의 값이 클 수록 분포는 완만해지고, 표준편차의 값이 작을수록 분포는 뾰족해진다.

분포가 완만해지면 가중치가 좀 더 균등해 질테니 좀 더 흐려질것이다.

그럼 표준편차가 큰 가우시안 필터(커널)는 블러 효과가 커지고 반대는 작아질것이다.

 

가우시안 블러는 쉽게 말하면 가우스 함수를 이용해 기존 box blur에서 픽셀별로 가중치를 다르게 적용시켜주는것이다.

 

그럼 Separable Gaussian blur는 Gaussian blur 의 커널(Gaussian filter)을 이용해 Separable Convolution을 수행하여 얻는 결과로 이해하면 될듯 하다.

 

수학적으로 자세하게 풀어나가지는 못했다. 다음에 좀 더 공부해서 수학적으로도 좀 더 풀어나가고싶다.

 

 

참고

https://www.analyticsvidhya.com/blog/2021/11/an-introduction-to-separable-convolutions/

 

An Introduction to Separable Convolutions

Separable Convolutions is a process in which a single convolution can be divided into two or more convolutions to produce the same output

www.analyticsvidhya.com

https://medium.com/@bdhuma/6-basic-things-to-know-about-convolution-daef5e1bc411

 

6 basic things to know about Convolution

In mathematics, convolution is an operation performed on two functions (f and g) to produce a third function. Convolution is one of the…

medium.com

https://en.wikipedia.org/wiki/Convolution

 

Convolution - Wikipedia

From Wikipedia, the free encyclopedia Integral expressing the amount of overlap of one function as it is shifted over another Visual comparison of convolution, cross-correlation, and autocorrelation. For the operations involving function f, and assuming th

en.wikipedia.org

https://en.wikipedia.org/wiki/Kernel_(image_processing)

 

Kernel (image processing) - Wikipedia

From Wikipedia, the free encyclopedia Matrix used in image processing to alter an image In image processing, a kernel, convolution matrix, or mask is a small matrix used for blurring, sharpening, embossing, edge detection, and more. This is accomplished by

en.wikipedia.org

https://en.wikipedia.org/wiki/Gaussian_blur

 

Gaussian blur - Wikipedia

From Wikipedia, the free encyclopedia Type of image blur produced by a Gaussian function The difference between a small and large Gaussian blur In image processing, a Gaussian blur (also known as Gaussian smoothing) is the result of blurring an image by a

en.wikipedia.org

 

'그래픽스' 카테고리의 다른 글

광선 추적(Raytracing)을 이용해 3d 구체 그리기  (4) 2024.02.07
Screen -> World 좌표계 변환  (0) 2024.02.03
Bloom  (0) 2024.02.02