import cv2
import matplotlib.pylab as plt
import numpy as np
img1 = cv2.imread('D:\\gudugudu\\Pictures\\weixin\\xiaotidaya.jpg', cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread('D:\\gudugudu\\Pictures\\weixin\\guoqing.jpg', cv2.IMREAD_GRAYSCALE)
img3 = cv2.imread('D:\\gudugudu\\Pictures\\weixin\\zhaoyang.jpg', cv2.IMREAD_GRAYSCALE)
img_x = cv2.resize(img1, (500, 500))
img_y = cv2.resize(img2, (500, 500))
img_z = cv2.resize(img3, (500, 500))
vc = cv2.VideoCapture("D:\\gudugudu\\Pictures\\weixin\\WeChat_20240706150425.mp4")
def cv_show(name, img):
cv2.imshow('name', img)
cv2.waitKey(0)
cv2.destroyWindow()
def tresh_Binary(img):#超过取最大值否则取0
ret, tresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)
cv_show('name', tresh)
def tresh_Binary_Inv(img):#超过取0否则取最大
ret, tresh = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV)
cv_show('name', tresh)
def tresh_Trunc(img):#大于阈值取阈值
ret, tresh = cv2.threshold(img, 127, 255, cv2.THRESH_TRUNC)
cv_show('name', tresh)
def tresh_Tozero(img): #大于不变,小于为0
ret, tresh = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO)
cv_show('name', tresh)
def tresh_Tozero_Inv(img): #小于不变,大于变0;tozero的反转
ret, tresh = cv2.threshold(img, 127, 255, cv2.THRESH_TOZERO_INV)
cv_show('name', tresh)
tresh_Binary_Inv(img_z)