[CV] Computer Vision(1-2): Image Processing - Neighborhood operator
๐Computer Vision ์ ๋ฆฌ
Neighborhood operator
- Neighborhood operator: pixel value computed using a collection of pixel values in a small neighborhood
Linear filter: a pixelโs value is a weighted sum of pixel values within a small neighborhood
- Correlation and convolution operators
1D Example
์ด๋ฏธ์ง f์ ํํฐ u๋ฅผ ์ ์ฉํจ
Correlation: ๊ทธ๋๋ก ๊ณฑํด์ ๋ํจ
Convolution: ํํฐ๋ฅผ ๋ค์ง์ด์ ๊ณฑํจ
2D Exmaple
Convolution: ํํฐ๋ฅผ ๋ค์ง์ โ ์๋ ์ ๋ ฅ๊ณผ ๊ฐ์ ๋ชจ์ ์ถ๋ ฅ
Correlation: ํํฐ๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉ โ ์ถ๋ ฅ์์ ํํฐ๊ฐ ๋ฐ์๋์ด ๋ณด์
Properties of Convolution(Correlation)
Correlation
and convolution
์ linear shift Invariant๋ฅผ ๊ณตํต ์ฑ์ง๋ก ๊ฐ์ง๋ค
- LSI(Linear Shift Invariant): ์ ํ & ์ด๋ ๋ถ๋ณ
- linearity:
$u(f_0โ+f1_โ)=uf_0โ+uf_1$ - shift-invariance(์ด๋ ๋ถ๋ณ์ฑ):
- ์ ๋ ฅ ์ด๋ํ๋ฉด ์ถ๋ ฅ๋ ๋๊ฐ์ด ์ด๋ํจ
- linearity:
์์ ํํ The shift invariance principle: ํ ํฝ์ ์ฉ ์ ์ฉํ ๊ฒฝ์ฐ๋ ์ ์ฒด์ ์ผ๋ก ์ ์ฉํ ๊ฒฝ์ฐ์ ํฝ์ ์ด ๊ฐ๋ค
- Correlation and convolution can be written as a matrix-vector multiplication: g = Uf
1์ฐจ์ 5pixel convolution ๊ฒฝ์ฐ๋ 5 by 5 ํ๋ ฌ๋ก ํํ ๊ฐ๋ฅ
Separable Filtering
- 2์ฐจ์์ผ ๊ฒฝ์ฐ $K^2$ operations per pixel์ ํ๊ฒ ๋๋ค
- ์ข ๋ ํจ์จ์ ์ผ๋ก ๊ณ์ฐํ ์ ์๋?
- filter์ shape์ (MxN) matrics์ฒ๋ผ ํํํ ์ ์๋ค โ ๊ทธ๊ฑธ
(mx1)
,(1xn)
์ผ๋ก ํ๋ ฌ์ seperateํด์ ๊ฐ๊ฐK operation
์ ํ๋ฉด ๋๋ค(2K)- ํ๋ ฌ์ seperateํ๋ค๋ ์๋ฏธ๋ 2๊ฐ์ 1D ํํฐ๋ก ๋ถํดํ๋ค๋ ๋ป
- Box filter(moving average filter): averages the pixels in a K x K window
- Bilinear filter(Bartlett filter): smooths image with a piecewise โtentโ function
- ์ค๊ฐ์ ํฐ ๊ฐ์ค์น๋ฅผ ์ฃผ๊ณ ์ถ์ ๋ ์ฌ์ฉ
- Gaussian filter: made by convolving the linear tent function with itself(์ค์ฌ ๊ฐ์กฐ, ๋
ธ์ด์ฆ ์ ๊ฑฐ)
- ์ค๊ฐ์ ๊ฐ์ฅ ํฐ ๊ฐ์ค์น๋ฅผ ์ฃผ๊ณ ์ฃผ๋ณ์ผ๋ก ๊ฐ์๋ก ์๊ฒ ์ ์ฉ
- Sobel filter: simple 3x3 edge extractor(combination of horizontal central difference and a vertical tent filter)
- 1~3๋ฒ์งธ๋ noise๋ฅผ ์์ ๊ธฐ ์ํ filter๋ผ๋ฉด, sobel์ ๊ทธ๋ฆผ์์ ์ฃ์ง(feature)๋ฅผ ๊ฒ์ถํ๋ค.
edge extractor
: edge์ ๊ฐ์ด ๋ณํด์ edge๊ฐ ๋ณํจ, ์์์์๋ ์ค๋ฅธ์ชฝ์์ ์ผ์ชฝ์ ๋นผ์ค๋ค.
- Simple corner detector: look forsimultaneous horizontal/vertical second derivatives (+diagonal edges)
- ์์ง, ์ํ์ ๋ณํ๋ฅผ filterํจ
Summed Area Table(Integral Image,์ ๋ถ ์์)
๋์ ์ฌ๊ฐํ ์์ญ์ ํฉ์ ๋น ๋ฅด๊ฒ ๊ตฌํ๋ ๊ธฐ์
๊ฐ์ ์ด๋ฏธ์ง์ ๋ค๋ฅธ ํฌ๊ธฐ์ box fliter๋ฅผ ์ ์ฉํด์ผํ๋ ๊ฒฝ์ฐ์ ์ ๋ถ ์์์ ์ฌ์ฉํ๊ฒ ๋๋ค
- ์๋ ๋ฐฉ์: MรM ์์ญ์ ํฉ์ ๊ตฌํ๋ ค๋ฉด $M^2$๋ฒ ๋ง์ ํ์
- Summed Area Table์ ์ฌ์ฉํ๋ฉด ํญ์ 4๋ฒ๋ง์ ํฉ ๊ณ์ฐ ๊ฐ๋ฅ
- ๋น ๋ฅธ
Box Filtering
๊ตฌํ ๊ฐ๋ฅ
- ๋น ๋ฅธ
๋์ ํฉ์ ๊ตฌํ๋ ์ ํ์
์ผ์ชฝ๋ถํฐ ๊ตฌํ๊ณ (2,2)์5
๋ฅผ ๊ณ์ฐํ๋ ค๋ฉด(3+2)+(3+1)-3+5 = 11
์ด ๋๋ค.
๊ฐ์ด๋ฐ์ 3x3 box filter๋ฅผ ์ ์ฉํ๋ ค๋ฉด
48 - 13 - 14 + 3
์ ๊ฐ์ด ๋๋ค. -13์ ํ๋ฉด ์ผ์ชฝ ์ธ๋ก 3,1,5,4๊ฐ ๋ ๋ผ๊ฐ๋ ์
Non-Linear Filtering
- Non-linear filters perform better in some applications (E.g. Edge-preserving filtering, removing shot noises)
Gaussian Filter(linear): ๋ ธ์ด์ฆ๋ ์ค์ง๋ง ๊ฒฝ๊ณ๋ ํ๋ ค์ง
Median Filter(non-linear): ๋ ธ์ด์ฆ๋ ์ฌ๋ผ์ง๊ณ ๊ฒฝ๊ณ๋ ์ ๋ช ํจ
Median filter
Median filter: selects the median value from each pixelโs neighborhood
- Can be implemented via linear-time algorithm(์ค์ธ์ฐ๊ธฐ)
Robust to removing shot noises while preserving edges
- ์์:
1
2
3
4
5
6
3x3 ์๋์ฐ:
[1 2 1]
[2 4 8]
[3 5 7]
โ ์ ๋ ฌ: [1,1,2,2,3,4,5,7,8] โ ์ค๊ฐ๊ฐ = 4
โ salt-pepper
์ฒ๋ผ ํ ํ๋ ํ์์ ๋ฐฐ์ ํ ์ ์์
Bilateral filter
Bilateral filter: reject pixels whose values differ too much from the central pixel value(in a soft way)