# -*- coding: utf-8 -*-
import cv2
#Ipythonで表示用の設定
import matplotlib.pyplot as plt
%matplotlib inline
#画像読込
in_img = cv2.imread("lena.jpg",0) #0:グレイ画像で読込
# Otsu's thresholding
ret,out_img = cv2.threshold(in_img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
#画像表示
plt.figure(figsize=(16,8))
plt.subplot(121)
plt.imshow(in_img,cmap = 'gray')
plt.subplot(122)
plt.imshow(out_img,cmap = 'gray')