OpenCVの公式ドキュメントに各フラグがどのよな処理をするか記載されているので,確認してください. cv2.threshold は二つの出力を返します.一つ目の出力 retval については後述します.二つ目の出力がしきい値処理された後の 二値画像 になります. コード : import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('gradient.png',0) ret,thresh1 = cv2.threshold(img,127,255,cv2.THRESH_BINARY) ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV) ret,thresh3 = cv2.threshold(img,127,2
![画像のしきい値処理 — OpenCV-Python Tutorials 1 documentation](https://cdn-ak-scissors.b.st-hatena.com/image/square/677ee364b70bd67ce511f051698f887380765c69/height=288;version=1;width=512/http%3A%2F%2Flabs.eecs.tottori-u.ac.jp%2Fsd%2FMember%2Foyamada%2FOpenCV%2Fhtml%2F_images%2Fmath%2F588a446d9a466ac81104cf588afec8ec9d713ffe.png)