# -*- coding: utf-8 -*-
import cv2
#Ipythonで表示用の設定
import matplotlib.pyplot as plt
%matplotlib inline
#画像読込
in_img = cv2.imread("lena.jpg",0) #0:グレイ画像で読込
#適応的2値化
out_img = cv2.adaptiveThreshold(in_img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2)
#画像表示
plt.figure(figsize=(16,8))
plt.subplot(121)
plt.imshow(in_img,cmap = 'gray')
plt.subplot(122)
plt.imshow(out_img,cmap = 'gray')