Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 딥러닝
- 학습
- 운영체제
- 공부
- CV
- C언어
- Windows 10
- c
- OpenCV
- 알고리즘
- linux
- 프로세스
- error
- 프로그래밍
- 영상처리
- 쉘
- 회귀
- 시스템프로그래밍
- 텐서플로우
- 턱걸이
- python
- Windows10
- 백준
- C++
- shell
- TensorFlow
- 코딩
- 리눅스
- Computer Vision
- 백준알고리즘
Archives
- Today
- Total
줘이리의 인생적기
CV - opencv(Python) 경계선 검출(edge detection) 본문
728x90
경계선 검출은 영상의 밝기가 낮은 값에서 높은 값으로, 또는 반대로 변하는 지점을 검출하는 과정이다.
객체의 경계를 검출함으로써 모양(shape), 방향(direction)을 탐지할 수 있다.
첫 번째로 1차 미분(prewitt, sobel, scharr) 방법을 통해 명암, 밝기 변화율을 검출한 후,
2차 미분(Laplacian) 방법을 이용하여 더욱 민감하게 검출한다.
prewitt 연산자 - 수평이나 수직 경계선에 민감
sobel 연산자 - 대각선 경계선에 민감
scharr 연산자 - sobel 보다 민감
Laplacian 연산자 - 모든 방향의 경계선을 강조
참고 사이트 : https://iskim3068.tistory.com/49
윤곽선 검출(Edge Detection) 에지 디텍션
영상에서 윤곽선 검출(Edge Detection)이 의미하는 것이 무엇인지 알아보자 1. 윤곽선&윤곽선 검출(Edge & Edge Detection ) Edge는 경계선, 윤곽선을 의미한다. 영상에서의 edge란 영상의 밝기가 낮은 값에서
iskim3068.tistory.com
1번 기본적인 prewitt, sobel, scharr, laplacian
2번 여러 laplacian (아래 코드를 통해 Laplacian 행렬 확인)
코드 원형 설명
#prewitt 연산자
def imageEdgePrewitt(image):
kernel_x = np.array([[-1, 0, 1],
[-1, 0, 1],
[-1, 0, 1]], np.float32)
kernel_y = np.array([[-1, -1, -1],
[0, 0, 0],
[1, 1, 1]], np.float32)
img_dx = imageFiltering(image, kernel_x)
img_dy = imageFiltering(image, kernel_y)
return img_dx + img_dy
#sobel 연산자
def imageEdgeSobel(image):
img_dx = cv2.Sobel(image, -1, 1, 0, ksize=3)
img_dy = cv2.Sobel(image, -1, 0, 1, ksize=3)
return img_dx + img_dy
#scharr 연산자
def imageEdgeScharr(image):
img_dx = cv2.Scharr(image, -1, 1, 0)
img_dy = cv2.Scharr(image, -1, 0, 1)
return img_dx + img_dy
#laplacian 연산자
def imageEdgeLaplacianCV(image):
return cv2.Laplacian(image, -1)
1번, 2번 코드 설명
더보기
from OpenCV_Functions import *
#1번 그림 코드
#이미지 설정
imagePath = "<이미지 경로>"
image = imageRead(imagePath)
imageShow("image", image)
#prewitt 연산자
image_Prewitt = imageEdgePrewitt(image)
imageShow("Prewitt", image_Prewitt)
#sobel 연산자
image_Sobel = imageEdgeSobel(image)
imageShow("Sobel", image_Sobel)
#scharr 연산자
image_Scharr = imageEdgeScharr(image)
imageShow("Scharr", image_Scharr)
#laplacian 연산자
image_LaplacianCV = imageEdgeLaplacianCV(image)
imageShow("LaplacianCV", image_LaplacianCV)
#2번 그림 코드
#여러 laplacian 연산자
laplacian_m4_kernel = np.array([
[0, 1, 0],
[1, -4, 1],
[0, 1, 0]], np.float32)
image_LaplacianFilter_m4 = imageFiltering(image, laplacian_m4_kernel)
imageShow("LaplacianFilter_m4", image_LaplacianFilter_m4)
laplacian_4_kernel = np.array([
[0, -1, 0],
[-1, 4, -1],
[0, -1, 0]], np.float32)
image_LaplacianFilter_4 = imageFiltering(image, laplacian_4_kernel)
imageShow("LaplacianFilter_4", image_LaplacianFilter_4)
laplacian_m8_kernel = np.array([
[1, 1, 1],
[1, -8, 1],
[1, 1, 1]], np.float32)
image_LaplacianFilter_m8 = imageFiltering(image, laplacian_m8_kernel)
imageShow("LaplacianFilter_m8", image_LaplacianFilter_m8)
laplacian_8_kernel = np.array([
[-1, -1, -1],
[-1, 8, -1],
[-1, -1, -1]], np.float32)
image_LaplacianFilter_8 = imageFiltering(image, laplacian_4_kernel)
imageShow("LaplacianFilter_8", image_LaplacianFilter_8)
cv2.destroyAllWindows()
'공부 > Computer Vision(py)' 카테고리의 다른 글
CV - opencv(Python) Morphology (0) | 2020.07.22 |
---|---|
CV - opencv(Python) Canny Edge (0) | 2020.07.21 |
CV - opencv(Python) Blur, GaussianBlur, MedianBlur (0) | 2020.07.17 |
CV - opencv(Python) addImage, addWeightedImage, imageThreshold (0) | 2020.07.16 |
CV - opencv(Python) 비디오에 라인, 원, 사각형 그리기 (0) | 2020.07.13 |