image morphological operations
Image morphological operation 알고리즘에 대해서 정리한다.
1. 개요
- Erosion
- Dilation
- Opening
- Closing
2. Background - 용어 정리
operation 의 동작을 알아보기 전에 용어 정리를 먼저 하려고 한다.
2.1. Structuring Element
Structuring Element 는 morphological operation 에서 사용하는 Kernel 또는 Mask 이다.
- 예시
- 4-neighborhood structuring element
- 8-neighborhood structuring element
- 그 외에 임의로 element 를 정의 할 수 있다.
2.2. Background pixel / Foreground pixel
Morphological Operations 을 수행하는 입력 영상은 Background pixel (intensity : 0) 과 Foreground pixel (intensity : 0) 이진화 된 영상이라고 가정한다.
3. Morphological Operations
3.1. Erosion (침식)
Erosion 을 한국말로 번역하면 ‘침식’ 이다. 말 그대로 이미지에서 foreground pixel 들을 깎아내리는 연산이다.
- 정의 : foreground pixel 중에서 모든 structuring element 가 ‘1’ (foreground pixel) 일 때만 foreground pixel 로 유지된다.
- Foreground pixel : strunturing element 중 1개라고 Foreground 가 아니면 Background 로 바뀐다.
- Background pixel : 유지.
- 사용예제
- small blob 을 제거할 때
- 1개의 connected component 를 2개로 분리할 때
3.2. Dilation (팽창)
Erosion 과 반대로 foreground pixel 들이 팽창하는 연산이다.
- 정의 : foreground pixel 의 모든 structuring element 는 foreground 로 팽창한다.
- Foreground pixel : 유지
- Background pixel : strunturing element 중 1개라고 Foreground 이면 Foreground 로 바뀐다.
- 사용예제
- 2개의 connected component 를 연결해서 1개로 만들 때
3.3. Opening
- 정의 : Erosion -> Dilation 을 순서대로 수행한다.
- Erosion : small blob 을 제거
- Dilation : 제거 되지 않고 남아 있는 component 들은 원래 상태의 size 로 복원한다.
- 사용예제
- small blob 을 제거할 때
- 1개의 connected component 를 2개로 분리할 때
Note : Erosion 과 사용목적이 같다. component 의 original size 를 유지해야 할 필요가 있을 때 opening 연산을 사용한다.
3.4. Closing
- 정의 : Dilation -> Erosion 을 순서대로 수행한다.
- Dilation : 끊어진 component 를 연결하거나 hole 을 매꾼다.
- Erosion : 원래 상태의 size 로 복원한다.
- 사용예제
- Component 내부의 Hole 을 매울 때
- 2개의 connected component 를 연결해서 1개로 만들 때
Note : Dilation 과 사용목적이 같다. component 의 original size 를 유지해야 할 필요가 있을 때 Closing 연산을 사용한다.
3.5. Morphological Gradient
- 정의 : Dilation - Erosion
- Dilation : image 를 팽창
- Erosion : (같은) image 를 축소
- diff(D, E) : component 의 boundary 만 남는다.
- 사용예제
- Image 의 Boundary 를 추출할 때 사용한다.
3.6. White Hat (Top Hat)
- 정의 : Original - Opening
A top hat operation is used to reveal bright regions of an image on dark backgrounds.
3.7. Black Hat
- 정의 : Original - Closing
We apply the black hat operator to reveal dark regions (i.e. the license plate text) against light backgrounds (i.e. the license plate itself).