이전글 보기 ▼
2019/12/11 - [Study/DAFIT] - 09 OpenCV 연습하기(1) - 06 Edge Detection(1)
09 OpenCV 연습하기(1) - 06 Edge Detection(1)
https://docs.opencv.org/3.4/d2/d2c/tutorial_sobel_derivatives.html OpenCV: Sobel Derivatives Prev Tutorial: Adding borders to your images Next Tutorial: Laplace Operator Goal In this tutorial you w..
whereisend.tistory.com
2019/12/10 - [Study/DAFIT] - 09 OpenCV 연습하기(1) - 05 Noise and Filtering(2)
09 OpenCV 연습하기(1) - 05 Noise and Filtering(2)
이미 medianblur를 사용했음. 2019/12/10 - [Study/DAFIT] - 09 OpenCV 연습하기(1) - 04 Noise and Filtering(1) 09 OpenCV 연습하기(1) - 04 Noise and Filtering(1) import numpy as np import cv2 from rand..
whereisend.tistory.com
마지막 문제는 Canny를 사용해서 edge detection을 한다.
Canny Edge Detection은 다음 단계로 구성되는 방법이다.
1. Gaussian Filter를 사용해서 노이즈를 감소시킨다.
노이즈가 있으면 엣지 검출에 방해가 되기 때문이다.
2. Graident 값 찾기.
Sobel 커널로 x, y방향의 그라디언트 값을 얻는다.
3. 최대값이 아닌 픽셀을 0으로 만든다.
이미지 전체를 스캔해서 gradient 방향으로 스캔한 곳들 중 gradient 최대값을 가진 픽셀을 찾는다.
4. low, high Threshold 값을 기준으로 엣지를 판단한다.
low threshold보다 낮으면 엣지가 아니라고 판단하고 high threshold보다 높으면 확실하게 엣지라고 판단한다.
https://en.wikipedia.org/wiki/Canny_edge_detector
Canny edge detector - Wikipedia
From Wikipedia, the free encyclopedia Jump to navigation Jump to search The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. It was developed by John F. Canny in 1986. Canny also
en.wikipedia.org
Canny를 포함해 앞서 풀었던 Sobel, Laplacian으로 edge detection하는 코드이다.
#edge는 픽셀값이 급격하게 변하는 지점이다.
#주변보다 1차 미분값이 큰 부분을 엣지로 검출하게된다.
#sobel x,y 방향 각각의 별도 커널을 사용해서 엣지 검출한다.
#sobel x는 수직선 방향
#sobel y는 수평선 방향
import cv2
from google.colab.patches import cv2_imshow
img_path='/content/drive/My Drive/다핏문제/909/lena.jpg'
#Sobel
img = cv2.imread(img_path,2)
res = cv2.Sobel(img,-1,1,1,ksize=3)
cv2_imshow(res)
#Laplacian
img = cv2.imread(img_path,2)
res = cv2.Laplacian(img,-1,ksize=1)
cv2_imshow(res)
#Canny
img = cv2.imread(img_path,2)
res = cv2.Canny(img,100,250) #low, high threshold에 따라 달라짐
cv2_imshow(res)
가장 극적으로 엣지를 흰색으로 표현하는 방법은 Canny임을 한 눈에 확인할 수 있다.
다만 Canny를 사용할 때 threshold 값을 어떻게 지정해주느냐에 따라 굉장히 자세한 부분들까지 검출하기도 하고 많이 생략해서 검출하기도 한다.
[DF909] OpenCV 연습하기 (1) : 다핏, 데이터사이언스 연습문제
🔥 문제 설명OpenCV Python을 이용하여 이미지 처리에 사용되는 필터링 및 엣지탐지 를 연습합니다.각종 영상 처리에서 기술표준으로 활용되는 '레나' 이미지를 활용해서 기초 기능과 필수 기술을 연습합니다.🔥 추천 대상영상 처리의 기초를 학습하고자 하는 자 OpenCV를 이용한 '필터 적용'과 '엣지 탐지'에 대한 기본적인 지식을 학습하고자 하는 자[DF907 : OpenCV 다루기 첫걸음]을 학습한 자🔥 학습 목표OpenCV는 오픈소스 컴퓨터 비전
www.dafit.me
'DAFIT > 909 - OpenCV 연습하기 (1)' 카테고리의 다른 글
<DAFIT> 09 OpenCV 연습하기(1) - 07 Edge Detection(2) (0) | 2019.12.11 |
---|---|
<DAFIT> 09 OpenCV 연습하기(1) - 06 Edge Detection(1) (0) | 2019.12.11 |
<DAFIT> 09 OpenCV 연습하기(1) - 05 Noise and Filtering(2) (0) | 2019.12.10 |
<DAFIT> 09 OpenCV 연습하기(1) - 04 Noise and Filtering(1) (0) | 2019.12.10 |
<DAFIT> 09 OpenCV 연습하기(1) - 03 Sharpening Filter (0) | 2019.12.10 |