Post

[CV] Computer Vision(1-2): Image Processing - Neighborhood operator

[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
    • alt text

1D Example

alt text

์ด๋ฏธ์ง€ f์— ํ•„ํ„ฐ u๋ฅผ ์ ์šฉํ•จ
Correlation: ๊ทธ๋Œ€๋กœ ๊ณฑํ•ด์„œ ๋”ํ•จ
Convolution: ํ•„ํ„ฐ๋ฅผ ๋’ค์ง‘์–ด์„œ ๊ณฑํ•จ

2D Exmaple

alt text

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(์ด๋™ ๋ถˆ๋ณ€์„ฑ):
    • ์ž…๋ ฅ ์ด๋™ํ•˜๋ฉด ์ถœ๋ ฅ๋„ ๋˜‘๊ฐ™์ด ์ด๋™ํ•จ

alt text

์ˆ˜์‹ ํ˜•ํƒœ The shift invariance principle: ํ•œ ํ”ฝ์…€์”ฉ ์ ์šฉํ•œ ๊ฒฝ์šฐ๋‚˜ ์ „์ฒด์ ์œผ๋กœ ์ ์šฉํ•œ ๊ฒฝ์šฐ์˜ ํ”ฝ์…€์ด ๊ฐ™๋‹ค

  • Correlation and convolution can be written as a matrix-vector multiplication: g = Uf

alt text

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 ํ•„ํ„ฐ๋กœ ๋ถ„ํ•ดํ•œ๋‹ค๋Š” ๋œป

alt text

  • 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ํ•จ

alt text

Summed Area Table(Integral Image,์ ๋ถ„ ์˜์ƒ)


๋„“์€ ์‚ฌ๊ฐํ˜• ์˜์—ญ์˜ ํ•ฉ์„ ๋น ๋ฅด๊ฒŒ ๊ตฌํ•˜๋Š” ๊ธฐ์ˆ 

๊ฐ™์€ ์ด๋ฏธ์ง€์— ๋‹ค๋ฅธ ํฌ๊ธฐ์˜ box fliter๋ฅผ ์ ์šฉํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ์— ์ ๋ถ„ ์˜์ƒ์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค

  • ์›๋ž˜ ๋ฐฉ์‹: Mร—M ์˜์—ญ์˜ ํ•ฉ์„ ๊ตฌํ•˜๋ ค๋ฉด $M^2$๋ฒˆ ๋ง์…ˆ ํ•„์š”
  • Summed Area Table์„ ์‚ฌ์šฉํ•˜๋ฉด ํ•ญ์ƒ 4๋ฒˆ๋งŒ์— ํ•ฉ ๊ณ„์‚ฐ ๊ฐ€๋Šฅ
    • ๋น ๋ฅธ Box Filtering๊ตฌํ˜„ ๊ฐ€๋Šฅ

alt text

๋ˆ„์ ํ•ฉ์„ ๊ตฌํ•˜๋Š” ์ ํ™”์‹
์™ผ์ชฝ๋ถ€ํ„ฐ ๊ตฌํ•˜๊ณ  (2,2)์˜ 5๋ฅผ ๊ณ„์‚ฐํ•˜๋ ค๋ฉด (3+2)+(3+1)-3+5 = 11 ์ด ๋œ๋‹ค.

alt text

๊ฐ€์šด๋ฐ์— 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)

alt text

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)

  • ๊ฐ€์ค‘์น˜๋ฅผ ์ค‘์•™ (ํ”ฝ์…€์—์„œ์˜ ๊ฑฐ๋ฆฌ + ์ƒ‰์ƒ ๊ฐ’)์— ๋Œ€ํ•ด์„œ ์ ์šฉํ•ด์„œ ๊ตฌํ•จ

  • alt text

    • ๊ฐ€๊นŒ์šฐ๋ฉด์„œ โ†’ ๊ฐ’์ด ๋น„์Šทํ•œ โ†’ ํ”ฝ์…€๋งŒ ์‚ด์‚ด ์„ž๋Š”๋‹ค
    • ๊ฒฝ๊ณ„๋Š” ์ง€ํ‚ค๊ณ , ๋…ธ์ด์ฆˆ๋งŒ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Œ
This post is licensed under CC BY 4.0 by the author.