3. area processes computer engineering, sejong university...

Post on 02-Nov-2019

7 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Image Processing

3. Area Processes

Computer Engineering, Sejong University

Dongil Han

2/80

Area Processing

uses the input pixel as well as the pixels around it to generate a new output pixel

Some area processing techniques

• Convolution

• Smoothing

• Sharpening

• Edge detection

• Derivative operators

• Median filtering

3/80

Convolution

Mask• usually 2-D matrix• m x n dimension &

usually m, n values are odd number

Convolution• centers on each pixel in

an input image and generates new output pixels

• new pixel is computed by multiplying each pixel value in the neighborhood with the corresponding weight in the mask and summing these products

4/80

1-D convolution example : 1x3 mask

1

1),(),0(),(

ttyxitmyxg

)2,0()1,0()1,0()0,0()0,0()1,0()1,0( imimimg

)3,0()1,0()2,0()0,0()1,0()1,0()2,0( imimimg

i

m

g

0 1 0

0 1 0

Convolution

5/80

1-D convolution example : 1x3 mask

i

m

g

-1 2 -1

-1 2 -1

1

1),(),0(),(

ttyxitmyxg

)2,0()1,0()1,0()0,0()0,0()1,0()1,0( imimimg

)3,0()1,0()2,0()0,0()1,0()1,0()2,0( imimimg

Convolution

6/80

2-D convolution example : 3x3 mask

11

1),(),(

1),(

ttysxitsm

syxg

)2,2()1,1()1,2()0,1()0,2()1,1()2,1()1,0()1,1()0,0()0,1()1,0()2,0()1,1()1,0()0,1()0,0()1,1()1,1(

imimimimimimimimimg

)9,4()1,1()8,4()0,1()7,4()1,1()9,3()1,0()8,3()0,0()7,3()1,0()9,2()1,1()8,2()0,1()7,2()1,1()8,3(

imimimimimimimimimg

Convolution

7/80

ba

bttysxitsm

asyxg ),(),(),(

2-D convolution example : mxn mask

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

If we let the resolution of an image be MxN, then

x= 0, 1, 2, …, M-1,y= 0, 1, 2, …, N-1

Convolution

8/80

convolution in image borders• zero padding : treat the empty cells in the convolution

window as zeros• start convolving with the pixel at (1,1) instead of the pixel

at (0,0). And also to end at (M-2, N-2) instead of (M-1,N-1)

• duplicate the border edges• wrap the image

Convolution

9/80

Graph of mask size vs. number of computations

Convolution

10/80

Convolution

Properties of mask coefficients• The bigger the sum of mask coefficients, the brighter the output

image• To preserve the brightness of output image, the sum of mask

coefficients should be ‘1’• If the sum of mask coefficients is less than 1, the output image

gets darker• The sum of coefficients is mostly 1 or 0

11/80

Blurring

Blurring• removes the finer details of an image• used to simulate a camera out of focus or de-emphasize a

background• accomplished through convolution• the bigger the mask, the greater the blurring effect and

the greater the computation time• effective way of reducing Gaussian noise• several kinds of blurring filters

- average filter- weighted average filter- low-pass filter

12/80

Average filter• generates neighborhood averaging in mask• 3x3 mask : all the coefficients equal 1/9• 5x5 mask : all the coefficients equal 1/25• removes extreme values in an image• effective way of reducing Gaussian noise in an image

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

1/25

Blurring

13/80

Average filter

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

mask

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

1/9

mask

50

50

50

50

50

50

50

50

50

Image

* = 50

40

20

80

30

90

60

70

50

10

Image

* = 50

Blurring

14/80

Average Filter Example

Original Image 3X3 mask

7X7 mask5X5 mask

15/80

Average Filter Example

16/80

Weighted average filter• approximates more closely to a Gaussian profile• the sum of coefficients is 1• well known weighted average filter : Gaussian smoothing

filter• controls the effective spread

22

22

)22(

),(

yx

eyxw

1/4

1/8

1/8

1/8

1/16

1/16

1/8

1/16

1/16

Blurring

17/80

Weighted average filter

mask

mask

50

50

50

50

50

50

50

50

50

Image

* = 50

40

20

80

30

90

60

70

50

10

Image

* = 48

1/4

1/8

1/8

1/8

1/16

1/16

1/8

1/16

1/16

1/4

1/8

1/8

1/8

1/16

1/16

1/8

1/16

1/16

Blurring

18/80

Weighted Average Filter Example

Original Image Gaussian smooth Filtering

19/80

Sharpening

Sharpening• has the opposite effect of blurring• also referred to as crispening• emphasizes the details in an image• increases local contrast• is based on the high-pass filter• several kinds of sharpening filters

9

-1

-1

-1

-1

-1

-1

-1

-1

5

-1

-1

-1

0

0

-1

0

0

5

-2

-2

-2

1

1

-2

1

1

20/80

Sharpening

21/80

High-pass filter• removes the low frequency components• show only high detail• the sum of coefficients is 0• original image is added back to generate sharpened

image• several kinds of high-pass filters

- (common) high-pass filter- unsharp masking- high-boost filter

Sharpening

22/80

High-pass filter• removes the low frequency components – e.g. mean value

of image• preserves the high frequency components – e.g. edge

component of image• used to emphasize the high image detail

8/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

Sharpening

23/80

High-pass filter

mask

mask

50

50

50

50

50

50

50

50

50

Image

* = 0

80

10

10

10

10

10

10

10

10

Image

* = 62

8/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

8/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

Sharpening

24/80

Unsharp masking• to subtract a low-pass filtered image from its original

• widely used because of its noise insensitive property

4/5

-1/5

-1/5

-1/5

0

0

-1/5

0

0

),(),(),( yxpasslow

fyxorgfyxsharp

f

8/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

Sharpening

25/80

3x3 Mean

Filter

Saturator+

++

-

Lum. In Lum. Out

Edge Signal

Mean Filtering

Result

Difference signal

Resulting Signal

Sharpening

Unsharp masking example

26/80

High-boost filter• computed by increasing the intensity of the original and

subtracting a low-pass filtered image

• when A = 1 : unsharp masking• when A > 1: a fraction of the original is added

w/5

-1/5

-1/5

-1/5

0

0

-1/5

0

0

),(),(),(_

yxpasslow

fyxorgfAyxboosthigh

f

w/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

w = 9A-1w = 5A-1

Sharpening

27/80

High-boost filter

mask

mask

50

50

50

50

50

50

50

50

50

Image

* = 11

Image

* = 80

10/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

80

10

10

10

10

10

10

10

10

10/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

-1/9

Sharpening

28/80

Original Image Sharpening

A =1.2 High-boostHigh-pass

Sharpening

29/80

Sharpening

30/80

Sharpening vs. blurring

31/80

Filtering

1-D Filter mask(ideal case)

f

Low-Pass Filter

f

High-Pass Filter

f

Band-Pass Filter

f

Band-Stop Filter

cutoff frequencyH(f)

H(f) H(f)

32/80

frequency sweep signal input

after high-pass filtering

after band-stop filtering

Properties of 1-D Filter mask

Filtering

33/80

Zone-plate image

Filtering

34/80

Zone-plate image

• center region : 0 frequency component

• moves to the outer region : frequency components goes to high

• widely used to test the filters

• widely used to test characteristics of display equipments

• an equation for making zone-plate

))cos(1(5.127),( 22 yH

xV

yxf

Filtering

35/80

Low-pass filteredimage

36/80

Originalimage

37/80

High-pass filteredimage

38/80

Originalimage

39/80

Laplacianfilteredimage

40/80

Edge• set of connected pixels that lie on the boundary between

two regions • (두 영역의 경계 면에 위치한 연결된 화소들의 집합)• holds much of the information in the image• tells where objects are, their shape, size, and texture• the difference between an edge and a boundary

- edge : local concept- boundary : more global idea

Edge Detection

41/80

Edge detection• detects meaningful discontinuities in gray-level image• first step in image segmentation(영역 분할)• image segmentation

- a field of image analysis- used to group pixels into regions to determine an

image’s composition• examples of edge profile

roof edge line edge step edge ramp edge

Edge Detection

42/80

Ideal edge and its model

Edge Detection

43/80

Simple edge detectors• Homogeneity operator

- the simplest edge detector

• Difference operator- the quickest edge detector

Edge Detection

44/80

Edge Detection

Homogeneity operator• determines the maximum value from a series of pixel

subtraction• subtracts each 8 surrounding pixels from the center

pixel of a 3x3 window• output : maximum of the absolute value of each

difference

45/80

Edge Detection

Difference operator • requires 4 subtractions per pixel

upper left – lower rightmiddle left – middle right lower left – upper right top middle – bottom middle

• output : maximum of the absolute value of each difference

46/80

(a) Original image (b) Edge map of homogeneity operator (c) Edge map of difference operator

Edge Detection

47/80

Derivative Operators

Derivative Operators• detects the edges using the first-order derivative or

second-order derivative of an image

• digital approximation is used for 1-, 2-order derivatives

• first-order partial derivative

• second-order partial derivative)

)()1( xfxfx

f

)()1( yfyfy

f

)(2)1()1(2

2xfxfxf

x

f

48/80

Derivative Operators

49/80

First-order derivative operators• the gradient of an image f(x,y) at location (x,y) is defined

as

• the magnitude of the gradient is

• the direction angle of the gradient (x,y) at (x,y)

y

fx

f

yGxG

f

)(1tan),(x

y

G

Gyx

||||22)( yx GGoryGxGmagf f

Derivative Operators

50/80

Properties of first-order derivative operators• consists of row detector Gx and column detector Gy

• the sum of mask coefficients is ‘0’

• several kinds of first-order derivative operators

1

0

0

0

-1

0

0

0

0

Gx

Roberts operator

Gy 1

0

0

0

0

0

0

-1

0

Prewitt operator

0

-1

1

0

-1

1

0

-1

1

0

0

0

-1

-1

-1

1

1

1

Sobeloperator

0

-2

2

0

-1

1

0

-1

1

0

0

0

-2

-1

-1

2

1

1

Frei-chenoperator

0

-

0

-1

1

0

-1

1

0

0

0

-

-1

-1

1

1

2

2

2

2

Derivative Operators

51/80

Properties of first-order derivative operators• Roberts operator

- smaller mask size- susceptible to noise

• Prewitt operator- widely used- sensitive to vertical and horizontal edges

• Sobel operator- widely used- sensitive to vertical and horizontal edges- more sensitive to diagonal edges than Prewitt operator- better noise suppression property than Prewitt operator

Derivative Operators

52/80

Prewitt operator

20

20

20

20

20

20

80

80

80

vertical edge

* = 0

horizontal edge

* = 18020

20

20

20

20

20

80

80

80

0

-1

1

0

-1

1

0

-1

1

0

0

0

-1

-1

-1

1

1

1

Gx

Gy

Derivative Operators

53/80

Sobel operator

20

20

20

20

20

20

80

80

80

* = 0

* = 24020

20

20

20

20

20

80

80

80

0

-2

2

0

-1

1

0

-1

1

0

0

0

-2

-1

-1

2

1

1

Gx

Gy

Derivative Operators

vertical edge

horizontal edge

54/80

Prewitt operator

20

20

40

20

20

20

80

60

80

* = 40

* = 16020

20

40

20

20

20

80

60

80

0

-1

1

0

-1

1

0

-1

1

0

0

0

-1

-1

-1

1

1

1

Gx

Gy

Derivative Operators

vertical edge

horizontal edge

55/80

Sobel operator

20

20

40

20

20

20

80

60

80

* = 60

* = 22020

20

40

20

20

20

80

60

80

0

-2

2

0

-1

1

0

-1

1

0

0

0

-2

-1

-1

2

1

1

Gx

Gy

Derivative Operators

vertical edge

horizontal edge

56/80

original

|||| yx GG xG

yG

Derivative Operators

57/80

original Roberts Operator

Sobel Operator

Prewitt Operator

Derivative Operators

58/80

Compass gradient operators

Compass gradient operators• find edges in eight different orientations • convolve an image with eight different convolution masks• output : maximum of all eight convolutions• several kinds of compass gradient operators

- Prewitt- Kirsh- Robinson 3-level- Robinson 5-level

59/80

Prewitt

-2

1

1

-1

-1

-1

1

1

1

west

-2

1

-1

-1

1

-1

1

1

1

northwest

-2

-1

1

-1

-1

1

1

1

1

-2

1

-1

1

1

-1

1

1

-1

north

-2

-1

1

1

-1

1

1

-1

1

-2

1

-1

1

1

1

-1

1

-1

northeast

-2

-1

1

1

1

1

-1

-1

1

-2

1

1

1

1

1

-1

-1

-1

southwest south southeast east

Compass gradient operators

60/80

Kirsh

0

-3

-3

-3

-3

-3

5

5

5

west

0

5

-3

-3

-3

-3

5

5

-3

northwest

0

-3

5

-3

-3

-3

5

-3

5

0

5

-3

-3

5

-3

-3

5

-3

north

0

-3

5

-3

-3

5

-3

-3

5

0

5

-3

5

5

-3

-3

-3

-3

northeast

0

-3

5

5

-3

5

-3

-3

-3

0

-3

-3

5

5

5

-3

-3

-3

southwest south southeast east

Compass gradient operators

61/80

Robinson 3-level

0

0

0

-1

-1

-1

1

1

1

west

0

1

-1

-1

0

-1

1

1

0

northwest

0

-1

1

-1

-1

0

1

0

1

0

1

-1

0

1

-1

0

1

-1

north

0

-1

1

0

-1

1

0

-1

1

0

1

-1

1

1

0

-1

0

-1

northeast

0

-1

1

1

0

1

-1

-1

0

0

0

0

1

1

1

-1

-1

-1

southwest south southeast east

Compass gradient operators

62/80

Robinson 5-level

0

0

0

-2

-1

-1

2

1

1

west

0

1

-1

-1

0

-2

1

2

0

northwest

0

-1

1

-1

-2

0

1

0

2

0

2

-2

0

1

-1

0

1

-1

north

0

-2

2

0

-1

1

0

-1

1

0

1

-1

1

2

0

-1

0

-2

northeast

0

-1

1

1

0

2

-1

-2

0

0

0

0

2

1

1

-2

-1

-1

southwest south southeast east

Compass gradient operators

63/80

0

1

-1

-1

0

-2

1

2

0

0

-1

1

-1

-2

0

1

0

2

Compass gradient operators

64/80

Derivative Operators

Laplacian• definition

• digital appriximation: x-directional 2-order partial derivative

• digital appriximation:

• final form

),(2),1(),1(2

2yxfyxfyxf

x

f

),(2)1,()1,(2

2yxfyxfyxf

y

f

2

2

2

22

y

f

x

ff

),(4)]1,()1,(),1(),1([2 yxfyxfyxfyxfyxff

65/80

Properties of Laplacian• produces sharper edges than first order derivatives • highlights edges in all directions• unacceptably sensitive to noise• produces double edges• unable to detect edge direction• several kinds of Laplacian operators

-4

1

1

1

0

0

1

0

0

4

-1

-1

-1

0

0

-1

0

0

-8

1

1

1

1

1

1

1

1

8

-1

-1

-1

-1

-1

-1

-1

-1

Derivative Operators

66/80

Derivative Operators

67/80original 1차미분 2차미분

Derivative Operators

68/80

LoG(Laplacian of Gaussian)• Laplacian is not used in the original form for edge detection• Gaussian smoothing filter is used before application of the

Laplacian• Gaussian smoothing filter example

• LoG(Laplacian of Gaussian)

deviationstandardisandyxrwhereerhr

222,)(2

2

2

2

2

24

22)(2

r

er

rh

Derivative Operators

69/80

Derivative Operators

70/80

LoG(Laplacian of Gaussian)• due to its shape, sometimes called the Mexican hat function• the larger the value of , the smaller the peak value and

the wider the convolution mask• the smaller the value of , the higher the peak value and

the narrower the convolution mask• the wider the mask, wider edge will be detected • the narrower the mask, sharp edge will be detected• insensitive to noise• similar to human visual perception model

2

2

24

22)(2

r

er

rh

Derivative Operators

71/80

sobeloriginal

gaussian smoothing

laplacian

LoGZero

crossing

Derivative Operators

72/80

Median Filtering

Median Filtering• replaces the value of a pixel by the median of the gray

levels in the neighborhood of that pixel• median : choose the center pixel after the sorting the

pixels in the window in ascending order• (마스크 내에 존재하는 화소들을 정렬(sorting) 한 후 중간에

위치하는 화소 값을 출력으로 사용) • the best-known order-statistics filter, nonlinear operator• reduces noise with preserving sharp edges and detail• particularly efficient for reducing impulse noise

- impulse noise : also known as salt-and-pepper noise- white and black dots in an image

73/80

5

6

3

4

5

5

13

29

7

6

26

27

9

5

8

6

5

5

9

45

9

28

27

31

7

6

15

32

32

33

5 6 267

8

6

9

6

28

27

15

9

A

B

Median Filtering• operation A : median {3, 5, 5, 4, 6, 5, 5, 5, 45}

= median {3, 4, 5, 5, 5, 5, 5, 6, 45} = 5• operation B : median {6, 5, 6, 5, 45, 6, 9, 9, 7}

= median {5, 5, 6, 6, 6, 7, 9, 9, 45} = 6

Median Filtering

74/80

Several kinds of Median Filters

Median Filtering

75/80

Median Filtering

76/80

Salt & pepper 잡음 Median filter 처리 결과 Mean filter 처리 결과

Median Filtering

77/80

Gaussian 잡음 Median filter 처리 결과 Mean filter 처리 결과

Median Filtering

78/80

Max filter

• Maximum window value is used

• removes dark spikes, pepper noise

• overall intensity of output image is increased

Min filter

• Minimum window value is used

• removes white spikes, salt noise

• overall intensity of output image is reduced

)},({max),(ˆ),(

tsgyxfxySts

Min/Max Filtering

)},({min),(ˆ),(

tsgyxfxySts

79/80

Midpoint filter

• simply computes the midpoint between the maximum and minimum values in the window

• works best for randomly distributed noise, like Gaussian and uniform noise

)}],({min)},({max[2

1),(ˆ

),(),(tsgtsgyxf

xyxy StsSts

Min/Max Filtering

80/80

pepper noise 추가 salt noise 추가

max filter 결과 min filter 결과

Min/Max Filtering

top related