キャニーエッジ検出

V2.4.11, V3.0.0
In [2]:
# -*- coding: utf-8 -*-
import cv2
import numpy as np

#Ipythonで表示用の設定
import matplotlib.pyplot as plt
%matplotlib inline

#画像読込
in_img = cv2.imread("lena.jpg")

#キャニーエッジ検出
edges = cv2.Canny(in_img,100,200)

#OpenCVがBGRなのでRGBに変換
disp_in_img  = cv2.cvtColor(in_img,  cv2.COLOR_BGR2RGB)

#画像表示
plt.subplot(121)
plt.imshow(disp_in_img)
plt.subplot(122)
plt.imshow(edges,cmap = 'gray')
Out[2]:
<matplotlib.image.AxesImage at 0x57d45f0>
inserted by FC2 system