Correlation and Convolution

Research/Robot Vision 2015. 5. 22. 18:17


Convolution.pdf









사실 associativity를 생각해보면 가우시안의 convolution은 결국 작은 값의 convolution을 여러번 반복한 것과 같다. 그런데 그것보다는 큰 convolution을 한 번에 수행하는 것이 훨씬 computationally 효율적이겠지!

(마치 1+1+1+1... 하는 것보다 큰 수를 한 번에 더하는 것과 같은 느낌이랄까..)




https://www.youtube.com/watch?v=Ma0YONjMZLI


correlation과 convolution의 가장 큰 차이점은 convolution이 associative하다는 것이다!!

The key difference between the two is that convolution is associative. 

(In general, people use convolution for image processing operations such as smoothing, and they use correlation to match a template to an image. Then, we don’t mind that correlation isn’t associative, because it doesn’t really make sense to combine two templates into one with correlation, whereas we might often want to combine two filter together for convolution. When discussing the Fourier series as a way of understanding filtering, we will use convolution, so that we can introduce the famous convolution theorem.)




Correlation은 아래와 같이 Image similarity를 보는 데 쓰인다. 

(만약 Image가 같은 이미지인데 일정한 상수값이 곱해진 이미지라면, ZNCC 값이 1 인 것으로 같은 이미지라는 것을 알 수 있음)






- 아래는 image에서의 FFT


The "mathematical equations" are important, so don't skip them entirely. But the 2d FFT has an intuitive interpretation, too. For illustration, I've calculated the inverse FFT of a few sample images:

enter image description here

As you can see, only one pixel is set in the frequency domain. The result in the image domain (I've only displayed the real part) is a "rotated cosine pattern" (the imaginary part would be the corresponding sine).

If I set a different pixel in the frequency domain (at the left border):

enter image description here

I get a different 2d frequency pattern.

If I set more than one pixel in the frequency domain:

enter image description here

you get the sum of two cosines.

So like a 1d wave, that can be represented as a sum of sines and cosines, any 2d image can be represented (loosely speaking) as a sum of "rotated sines and cosines", as shown above.

when we take fft of a image in opencv, we get weird picture. What does this image denote?

It denotes the amplitudes and frequencies of the sines/cosines that, when added up, will give you the original image.

And what is its application?

There are really too many to name them all. Correlation and convolution can be calculated very efficiently using an FFT, but that's more of an optimization, you don't "look" at the FFT result for that. It's used for image compression, because the high frequency components are usually just noise.




* ref

[1] https://moocs.qut.edu.au/courses/791/learn

[2] https://www.youtube.com/watch?v=Ma0YONjMZLI

[3] http://dsp.stackexchange.com/questions/1637/what-does-frequency-domain-denote-in-case-of-images

[4] Correlation and Convolution, Class Notes for CMSC 426, Fall 2005 David Jacobs

     (Important!)


설정

트랙백

댓글

Monadic operation, Diadic operation, Spatial operation

Research/Robot Vision 2015. 5. 22. 14:54






diadic operation에서 주의해야 할 점..



재미있는 예는 두 사진을 합성하는 예가 있다. 

각각 0 과 1 의 logical image를 만들어서 1을 마스크로 생각하고...

원본 이미지와 multiplication을 하면.. 필요한 이미지만 따올 수가 있게 된다.

이렇게 해서 합성하면 된다~~






근데 window가 edge에서 fall off 해버리는 문제는 어떨까?



또 다른 문제가 있다. Window가 직사각형 모양인데, 진정한 평균의 의미를 가질 수 있는가?

(각각의 픽셀 값이 동등한 weight로 더해져서는 안되겠지.. 거리가 다르니까!)



그래서 거리의 문제를 없애기 위해서 circle을 적용해 보려고 했더니, digital image의 픽셀 자체가 circle을 만들 수가 없는 형태...


그래서 어느 정도 cover가 되는 지에 따라서 weight를 줄 수 있겠지!



이렇게, 마스크에 weight를 곱해주어서 계산을 한다.. 이 때 곱해주는 weight를 이루는 창을 kernel이라고 한다!!




그런데 이 kernel의 값이 너무 크면 안되니까 normalize를 해 준다.



가장 대표적으로 많이 쓰이는 kernel에는 gaussian kernel이 있다.




Gaussian kernel을 사용하기 위해서 가장 중요한 것 중 하나는 적절한 standard deviation을 설정하는 것!
(It controls the width of the kernel)

일반적으로는 kernel의 넓이(2h+1)의 절반(h)은 3 * standard deviation임!


실제 테스트를 해보면, 비슷한 블러링 효과를 주도록 파라미터를 조정해서 비교해보면 아래와 같다.

위 사진은 31 * 31 사이즈의 window를 적용한 operation이고 아래는 standard deviation 10의 gaussian kernel을 적용한 operation이다. 

위 사진에서는 window의 isotropic하지 않은 특성 때문에 ringing effect가 발생하는 것이 보인다. 
(눈 주변. 입 주변 등..)



* ref

[1] https://moocs.qut.edu.au/courses/791/learn



'Research > Robot Vision' 카테고리의 다른 글

Aliasing  (0) 2015.06.29
Morphology - Erode / Dilate image  (0) 2015.05.27
Correlation and Convolution  (1) 2015.05.22
디스플레이 장치에서 감마(gamma)란 무엇인가?  (0) 2015.05.21

설정

트랙백

댓글