4장 이미지와 그래픽스 : 영상 처리...

82
영상 처리 기법 김성영교수 금오공과대학교 컴퓨터공학부

Transcript of 4장 이미지와 그래픽스 : 영상 처리...

Page 1: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

영상 처리 기법

김성영교수

금오공과대학교

컴퓨터공학부

Page 2: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

2

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 3: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

3

Pixel Point Processing

이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과영상의동일한위치에출력하는연산

영상의밝기및대비조정

• 영상밝기 (Image brightness): 영상의픽셀값에대한전반적인밝기정도

• 영상대비 (Image contrast): 영상내의 gray level 분포및범위에대한측도

the difference between the brightness and darkest pixel values and

how the intermediate values are arranged

주요처리방법• 영상대수 (Image Algebra): 단일영상혹은다중영상에적용가능

• 그레이스케일변경 (Gray-Scale Modification)

• 히스토그램변경 (Histogram Modification)

Page 4: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

4

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 5: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

5

산술 연산: 단일영상

덧셈연산

• 일정한값을더하여영상을밝게만듦

뺄셈연산

• 일정한값을빼서영상을어둡게만듦

곱셈연산

• 픽셀의값에비례하여영상의밝기를증가시킴

밝은곳은더욱밝게, 어두운곳은조금밝게하여영상의 contrast를향상

나눗셈연산

• 픽셀의값에비례하여영상의밝기를감소시킴

영상의 contrast를감소

• 움직임을찾아내거나조명의비균일성을바로잡는데사용

Page 6: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

6

산술 연산: 단일영상 cont’d

덧셈연산 (+50) 뺄셈연산 (-50)

곱셈연산 (*1.2) 나눗셈연산 (/1.2)

Page 7: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

7

산술 연산: 다중영상

덧셈연산

First Original Second Original Addition of images

Original image Gaussian noise Addition of images

Page 8: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

8

산술 연산: 다중영상 cont’d

뺄셈연산

a. Original scene b. Same scene later

Subtraction of scene a from scene b Subtracted image with thresholding

Page 9: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

9

논리 연산

9

마스킹처리, 특징추출, 형태분석등에사용

• 마스킹처리를위한마스크는주로이진영상을사용

AND, OR, NOT, NAND, NOR, XOR 등

a. Original image b. Image mask (AND) c. ANDing a and b

d. Image mask (OR) e. ORing a and d

Page 10: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

Lab.

Page 11: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

11

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

•그레이스케일변경이란무엇인지설명할수있다.• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 12: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

12

Gray-Scale Modification

영상밝기와대비를조정하기위해매핑함수사용

• Ex) (10,50) 범위의 gray level을 (10,250) 범위로확장

M[I(x, y)] = 6[I(x, y)] – 50 즉,

≤<≤≤−<≤

=255),(50),(50),(1050)],([6

50),(0),()],([

yxIforyxIyxIforyxI

yxIforyxIyxIM

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

10 5030

O(x, y) = M[I(x, y)]

Page 13: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

13

Gray-Scale Modification cont’d

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

(r1, s1)

(r2, s2)

General Form of Gray-Scale Modification

Page 14: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

14

Gray-Scale Compression

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

Page 15: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

15

Gray-Scale Stretching

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

50 200

Page 16: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

16

Gray-Scale Stretching cont’d

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

28 75

Page 17: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

17

Gray-Level Slicing

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

150 200

Page 18: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

18

Gray-Level Slicing cont’d

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

Page 19: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

19

Gray-Level Thresholding

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

T

Page 20: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

20

Gray-Level Negation

original gray-level values

mod

ified

gra

y-le

vel v

alue

s

Page 21: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

Lab.

Page 22: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

22

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

•히스토그램변경이란무엇인지설명할수있다. 픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 23: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

23

Gray-Level Histogram

각 gray level을갖는픽셀의수혹은총픽셀수에대한비율을표시한함수

• 픽셀값들을막대그래프혹은직선그래프로표시

x축: gray level, y축:픽셀의수를표시

8-bit grayscale image Histogram of the image

number of

pixels

gray level0 255

Page 24: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

24

Gray-Level Histogram cont’d

with a small(wide) spread => low(high) contrast

clustered at the low(high) end of the range =>dark(bright) image

Page 25: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

25

Histogram Modification

히스토그램에기반을두고영상의밝기및대비변경

Modification by a mapping function

• Focus on the histogram shape and range

Fields histogram stretching

histogram shrinking

histogram sliding

histogram equalization

Original Histogram

Histogram Stretch

Histogram Shrink

Histogram Slide

Page 26: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

26

Histogram Stretching

Increase contrast of a low contrast image

Mapping Function

IMAX : largest gray-level value in the image I(x,y)IMIN : smallest gray-level value in I(x,y)SMAX : maximum desired gray-level value in the stretched histogram

SMIN : minimum desired gray-level value in the stretched histogram

MINMINMINMAX

MINMAX SIyxIIISSyxI +−

−−

= ]),([),('

Page 27: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

27

Histogram Stretching cont’d

50 100

10 210

75

110

55

30

x

y

)10(:)10210()50(:)50100( −−=−− yx

)10210(*)50()50100(*)10( −−=−− xy

10)50()50100()10210(10

)50100()10210(*)50(

+−−−

=+−

−−= xxy

minminminmax

minmax' )),(()()(),( SIyxI

IISSyxI +−

−−

=

Page 28: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

28

Low-contrastimage

Histogram of low-contrastimage

Image after histogramstretching

Histogram ofimage afterstretching

Histogram Stretching cont’d

Page 29: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

29

클리핑(Clipping)의필요성

Original image Histogram of original image

Histogram Stretching cont’d

Page 30: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

30

histogramstretching

withoutclipping

Histogram of image (c)

histogramstretching with

clipping 3% low and high

values

Histogram of image (e)

Histogram Stretching cont’d

Page 31: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

31

Histogram Shrinking

Decrease image contrast by compressing the gray levels

Mapping Function

MINMINMINMAX

MINMAX SIyxIIISSyxI +−

−−

= ]),([),('

IMAX : largest gray-level value in the image I(x,y)IMIN : smallest gray-level value in I(x,y)SMAX : maximum desired in the compressed histogram

SMIN : minimum desired in the compressed histogram

Page 32: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

32

Histogram Shrinking cont’d

Original image

Image aftershrinking

to the range[75, 175]

Histogram of originalimage

Histogram of shrinkedimage

Page 33: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

33

Histogram Sliding

Make an image darker or lighter but retain the relationship between gray-level values

Mapping Function

offsetyxIyxS += ),(),(

offset : amount to slide the histogram

Page 34: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

34

Originalimage

positive-value

histogramsliding

Histogram of original image

Histogram of image aftersliding

Histogram Sliding cont’d

Page 35: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

35

Histogram Equalization

목적

한쪽으로치우친밝기의분포를재분배해서그레이레벨의발생빈도를균등하게분포하도록만듦

Page 36: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

36

Histogram Equalization cont’d

명암대비

높은명암대비 좋은명암대비

Page 37: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

37

히스토그램균일화절차

① 입력영상의히스토그램값을누적시켜히스토그램누적합을구함

② 히스토그램의누적합을전체픽셀의개수로나누어값을정규화함

③ 정규화된값에최대명암도값을곱한후반올림을수행

④ 입력영상의명암도에대한변환값으로대응시킴

Histogram Equalization cont’d

Page 38: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

38

Example

0 7

1018

27 29

43 44 49 51

0 7

108 9

2

14

1

5

2

0 7

108

1115

7

)7,7,6,6,4,4,2,1()00.7,73.6,04.6,90.5,98.3,71.3,47.2,37.1(

751

)51,49,44,43,29,27,18,10(

≈≈

×

히스토그램 누적값 균일화결과

Histogram Equalization cont’d

Page 39: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

39

균일화과정

4 5 3 6 7

4 2 2 4 6

0 2 2 5 7

0 0 2 3 5

0 1 2 4 4

픽셀값 개수 누적값 균일화 반올림

0 10 10 1.37 1

1 8 18 2.47 2

2 9 27 3.71 4

3 2 29 3.98 4

4 14 43 5.90 6

5 1 44 6.04 6

6 5 49 6.73 7

7 2 51 7.00 7

6 6 4 7 7

6 4 4 6 7

1 4 4 6 7

1 1 4 4 6

1 2 4 6 6

4351

* 7 = 5.901051

* 7 = 1.37

균일화를위한공식

Normalization =전체픽셀의수

누적값X 최대그레이레벨

Histogram Equalization cont’d

Page 40: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

40

Originaldark image

Image afterhistogram

equalization

Histogram of originalimage

Histogram of equalizedimage

Histogram Equalization cont’d

Page 41: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

41

Original light image

Light image after histogram

equalization

Histogram of originalimage

Histogram of equalizedimage

Histogram Equalization cont’d

Page 42: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

42

Original Histogram Equalization

Histogram Equalization cont’d

Page 43: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

43

Histogram Equalization cont’d

Page 44: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

Lab.

Page 45: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

45

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 46: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

46

픽셀 그룹 처리

픽셀그룹처리란? 출력영상의새로운픽셀의값을결정하기위해해당픽셀뿐만아니라그주위의이웃픽셀들도함께고려하는공간영역연산을의미

컨볼루션(convolution) 연산으로처리

• 처리하고자하는픽셀값을이웃픽셀의각각에대응하는 2차원배열내의가중치를곱하고그값들을모두더한값으로변경하는연산

• 2차원배열: 마스크(mask), 필터(filter), 템플릿(template), 커널(kernel)

Page 47: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

47

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 48: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

48

Convolution

48

중심픽셀및그인접한픽셀들을대응하는 2차원배열형태의가중치(계수)와각각곱하고이들을모두더한후에이값으로중심픽셀의값을변경하는연산

2차원배열을지칭하는용어

• 마스크(mask), 필터(filter), 템플릿(template), 커널(kernel)

Linear spatial filtering을위해사용

∑∑−= −=

++=∗=a

as

b

bttysxftshyxfyxhyxg ),(),(),(),(),(

단,a = (m-1) / 2b = (n-1) / 2

입력영상(f )의크기: M x N마스크(h)의크기: m x n

Page 49: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

49

Convolution cont’d

’ ’ ’’ ’ ’

’ ’ ’

=*’

=*’

. . .

++ +

※영상내의모든 pixel에대해반복적으로처리

=*’

Page 50: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

50

영상의 경계 처리 방법

Page 51: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

51

영상의 경계 처리 방법 cont’d

① 상수값(예를들어, 0)을덧붙임

② 경계에있는픽셀값을복사

③ 영상을주기적인신호로해석하여맞은편픽셀값을복사(Wrap-around)

④ 모든이웃픽셀이정의되는위치(예를들어, (1,1))에서컨볼루션연산을시작하고출력영상의경계부분은입력영상의값으로복사

Page 52: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

52

선형 공간 필터

대표적인선형공간필터링연산

영상평활화 (Image Smoothing 혹은 image blurring)

• 영상을부드럽게표현하거나노이즈(noise)를제거하기위해사용

• 평균값필터링(mean filtering) 및중간값필터링(median filtering) 연산을통해수행가능

영상첨예화 (Image Sharpening)

• 영상의상세한정보를강화시키는연산

상세정보란영상내부에포함된물체의경계혹은질감의경계등을의미

• Laplacian-type 및 difference-type의 enhancement filter 사용

에지검출 (Edge Detection)

• 영상내에포함된에지를추출하는연산

에지란짧은범위에서급격하게밝기가변화는지점을의미

Page 53: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

53

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

•평활화의기능및방법을설명할수있다.• 첨예화의기능및방법을설명할수있다.

• 에지검출의기능및방법을설명할수있다.

Page 54: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

54

Image Smoothing

Mean Filtering (평균값필터링) common spatial convolution masks

• 모든계수가양수이고전체합이 1인마스크가사용

111111111

91

111121111

101

212141212

161

121242121

161

Page 55: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

55

Image Smoothing cont’d

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 100 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 20 20 20 10 10 10 10

10 20 20 20 10 10 10 10

10 20 20 20 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

Mean filtering

Page 56: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

56

Originalimage

3*3Arithmeticmean

5*5 7*7

Image Smoothing cont’d

Page 57: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

57

Median Filtering (중간값필터링) Nonlinear filter

Center pixel is replaced with the median, or center, value present among its neighbors

Useful for removing salt-, pepper-, or salt-and-paper noise

743543655

(3,3,4,4,5,5,5,6,7)

743553655

Image Smoothing cont’d

Page 58: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

58

Originalimage

MeanFiltering

MedianFiltering

Image Smoothing cont’d

Page 59: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

59

Originalimage

3*3Medianfilter

5*5 7*7

Image Smoothing cont’d

Page 60: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

Lab.

Page 61: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

61

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

•첨예화의기능및방법을설명할수있다.• 에지검출의기능및방법을설명할수있다.

Page 62: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

62

Image Sharpening

62

High-pass filtering 고주파성분은통과시키고저주파성분은차단

• 영상의상세정보를강화시키는연산

• 고주파통과필터링영상은원영상과저주파통과필터링영상의차로써얻을수있음

),(),(),( yxfyxfyxf LH −=

1 1 11 1 8 19

1 1 1

− − − × − − − − −

=

111111111

91

000010000

Page 63: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

63

Image Sharpening cont’d

-10 -20 -10 -20 -10 0 0 0

-20 40 20 40 -20 0 0 0

-30 20 70 20 -30 0 0 0

-20 40 20 40 -20 0 0 0

-10 -20 -30 -20 -10 0 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0

High-passfiltering

10 10 10 10 10 10 10 10

10 20 20 20 10 10 10 10

10 20 30 20 10 10 10 10

10 20 20 20 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

10 10 10 10 10 10 10 10

Page 64: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

64

Laplacian-type filtering (라플라시안타입필터링) 고주파통과필터에서발생하는낮은공간주파수성분손실의문제점을보완함

샤프닝필터의예

• 모든계수의합은 1임

−−−

010151

010

−−−

121252

121

Original image Contrast-enhanced

Image Sharpening cont’d

Page 65: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

65

Unsharp Masking (언샤프마스킹) Representative of practical image sharpening methods

InputImage

LowpassFilter

HistogramShrink

SubtractImages

HistogramStretch

ResultImage

+

Image Sharpening cont’d

Page 66: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

66

),(),()1()},(),({),(

),(),(),(

crLcrIcrLcrIcrI

crHcrIcrE

λλλλ

−+=−+=

+=

),( crI

),( crL

),(),( crLcrI −

)},(),({),(),( crLcrIcrIcrE −+= λ

Image Sharpening cont’d

Page 67: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

67

OriginalImage

Unsharpmaskinglower limit=0, upper=100,2% low andhigh clipping

Unsharpmaskinglower limit=0, upper=200,2% low andhigh clipping

Unsharpmasking

lower limit=0, upper=150,2% low and

high clipping

Image Sharpening cont’d

Page 68: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

Lab.

Page 69: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

69

학습 목표

단일픽셀처리기법의의미를설명할수있다.

단일픽셀처리기법의종류를구분하여설명할수있다.

• 영상대수기법을구분하여설명할수있다.

• 그레이스케일변경이란무엇인지설명할수있다.

• 히스토그램변경이란무엇인지설명할수있다.

픽셀그룹처리기법의의미를설명할수있다.

컨볼루션연산및경계처리방법에대해설명할수있다.

픽셀그룹처리기법의종류를구분하여설명할수있다.

• 평활화의기능및방법을설명할수있다.

• 첨예화의기능및방법을설명할수있다.

•에지검출의기능및방법을설명할수있다.

Page 70: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

70

Edge Detection

Ideal Edge vs. Real Edge

Page 71: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

71

Edge Detection cont’d

에지검출방법

1차미분값을이용

• Prewitt, Sobel, Roberts 등

2차미분값을이용

• Laplacian(라플라시안)

darkbright

change of brightness

1st-order derivativepositivepeak

negativepeak

2nd-order derivative

Page 72: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

72

1차미분연산자

밝기변화율즉기울기를검출하기위한방법

∂∂

∂∂

=

=∇

yf

xf

G

Gf

y

x

[ 1, ] [ , ], [ , 1] [ , ]x yG f x y f x y G f x y f x y≅ + − ≅ + −

기울기 벡터 의 크기 G 와 축에 대한 각도인 방향

2 2 max( , )x y x y x yG G G G G G G= + ≈ + ≈

1 (x, y) tan y

x

GG

α − =

f∇ αx

Edge Detection cont’d

Page 73: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

73

Prewitt 연산자

• 대각선보다수평이나수직에지에더민감

Sobel연산자

• 대각선방향의에지에더민감

−−−

=1 0 11 0 11 0 1

),( yxhx

−−−=

1 1 1 0 0 0 111

),( yxhy

−−−

=1 0 12 0 21 0 1

),( yxhx

−−−=

1 2 1 0 0 0 121

),( yxhy

[ 1, ] [ , ], [ , 1] [ , ]x yG f x y f x y G f x y f x y≅ + − ≅ + −

( , ) ( , ), ( , ) ( , )x x y yG h x y f x y G h x y f x y= ∗ = ∗

Edge Detection cont’d

Page 74: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

74

Roberts 연산자

• 매우빠른계산속도를나타내나잡음에매우민감함

에지검출결과

−=

0 0 10 1 0 0 0 0

),( yxhx

−=

0 0 0 0 1 0 0 0 1

),( yxhy

(a) 원영상 (b) 프리위트 (c) 소벨 (d) 로버츠

1차 미분 연산자 적용 결과

Edge Detection cont’d

Page 75: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

75

Laplacian (라플라시안) 대표적인 2차미분연산자로모든방향의에지를강조

2

2

2

22

yf

xff

∂∂

+∂∂

=∇

2

2

( [ 1, ] [ , ]) [ 1, ] [ , ]xGf f x y f x y f x y f x yx x x x x

∂∂ ∂ + − ∂ + ∂= = = −

∂ ∂ ∂ ∂ ∂

( [ 1, ] [ , ]) ( [ , ] [ 1, ]) [ 1, ] 2 [ , ] [ 1, ]f x y f x y f x y f x y f x y f x y f x y= + − − − − = + − + −

[ ]2 ( , 1) ( 1, ) ( 1, ) ( , 1) 4 ( , )f f x y f x y f x y f x y f x y∇ = + + − + + + − −

2

2 [ , 1] 2 [ , ] [ , 1]f f x y f x y f x yy

∂= + − + −

0 1 01 4 10 1 0

0 1 01 4 10 1 0

− − − −

1 1 11 8 11 1 1

1 1 11 8 11 1 1

− − − − − − − −

(a) (b) (c) (d)

라플라시안 필터들

Edge Detection cont’d

Page 76: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

76

2차미분연산자를적용한에지검출결과

(a) 원영상(b) 4 방향라플라시안

(c) 8 방향라플라시안

(d) 가우시안의라플라시안

Edge Detection cont’d

Page 77: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

77

First vs. Second-order derivative

Edge Detection cont’d

Page 78: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

78

참고: 칼라 영상 처리

컬러영상에대한영상처리

RGB 영상을그대로사용하는방법

HIS(HLS) 영상으로변환하여처리하는방법

입력영상

R

G

B

R′

G′

B′

결과영상

RGB 처리

입력영상

R

G

B

R′

G′

B′

결과영상

H

S

I

H′

S′

I′

HSI 처리

Page 79: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

79

참고: 칼라 영상 처리 cont’d

I 성분 히스토그램 균일화 처리 RGB 성분별 히스토그램 균일화 처리

Page 80: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

Lab.

Page 81: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

81

학습정리 (1)

1. 단일 픽셀 처리 기법− 이웃 픽셀과는 독립적으로 입력 영상의 각 픽셀 값을 변환한 후

결과 영상의 동일한 위치에 출력하는 연산

− 영상의 밝기 및 대비 조정

− 영상대수 (Image Algebra)• 덧셈연산, 뺄셈연산, 곱셈연산, 나눗셈연산, 논리연산

− 그레이스케일변경 (Gray-Scale Modification)• Gray-Scale Compression, Gray-Scale Stretching, Gray-Level Slicing, Gray-

Level Thresholding, Gray-Level Negation

− 히스토그램변경 (Histogram Modification)• histogram stretching, histogram shrinking, histogram sliding, histogram

equalization

Page 82: 4장 이미지와 그래픽스 : 영상 처리 기법contents.kocw.or.kr/document/04_ImageProcessing.pdf · 3. Pixel Point Processing. . 이웃픽셀과는독립적으로입력영상의각픽셀값을변환한후결과

82

학습정리 (2)

2. 픽셀 그룹 처리 기법− 출력 영상의 새로운 픽셀의 값을 결정하기 위해 해당 픽셀 뿐만

아니라 그 주위의 이웃 픽셀들도 함께 고려하는 공간 영역 연산

− 컨볼루션(convolution)• 처리하고자하는픽셀값을이웃픽셀의각각에대응하는 2차원배열내

의가중치를곱하고그값들을모두더한값으로변경하는연산

− Image Smoothing• Mean Filtering, Median Filtering

− Image Sharpening• High-pass Filtering, Laplacian-type Filtering, Unsharp Masking

− Edge Detection• Prewitt, Sobel, Roberts, Laplacian