import cv2
import matplotlib.pylab as plt
import numpy as np
img1 = cv2.imread('D:\\gudugudu\\Pictures\\weixin\\xiaotidaya.jpg', cv2.IMREAD_ANYCOLOR)
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")
#梯度计算
#Soble算子 det = cv2.Soble(src, drpth, dx, dy, ksize);上下,左右的差异
#计算方法: 右-左*系数, 上-下*系数;
def soble(img):
soblex = cv2.Soble(img, cv2.CV_64F, 1, 0, ksize = 3)
soblex = cv2.convertScaleAbs(soblex)
cv2.imshow('name', soblex)
cv2.waitKey(0)
cv2.destroyAllWindows()
#分别计算xy再求和;
def Soblexy(img):
soblex = cv2.Soble(img, cv2.CV_64F, 1, 0, ksize = 3)
sobley = cv2.Soble(img, cv2.CV_64F, 0, 1, ksize = 3)
soblexy = cv2.addWeighted(soblex, 0.5, sobley, 0.5, 0)
cv2.imshow('name', soblexy)
cv2.waitKey(0)
cv2.destroyAllWindows()
#scharr算子: 数值大一些,结果的差异更加敏感
#laplacian算子: 对于差异更加敏感, 但是对于噪点的判断有误
def scharr(img):
scharrx = cv2.Scharr(img, cv2.CV_64F, 1, 0)
scharry = cv2.Scharr(img, cv2.CV_64F, 0, 1)
scharrx = cv2.convertScaleAbs(scharrx)
scharry = cv2.convertScaleAbs(scharry)
scharrxy = cv2.addWeighted(scharrx, 0.5, scharry, 0.5, 0)
cv2.imshow('name', scharrxy)
cv2.waitKey(0)
cv2.destroyAllWindows()
def LapLacion(img):
laplacion = cv2.Laplacian(img, cv2.CV_64F)
laplacion = cv2.convertScaleAbs(laplacion)
cv2.imshow('name', laplacion)
cv2.waitKey(0)
cv2.destroyAllWindows()
opencv_day6
咕噜咕嘟嘟嘟2024-08-06 16:31
相关推荐
Funny_AI_LAB13 小时前
李飞飞联合杨立昆发表最新论文:超感知AI模型从视频中“看懂”并“预见”三维世界数据皮皮侠17 小时前
区县政府税务数据分析能力建设DID(2007-2025)极小狐18 小时前
比 Cursor 更丝滑的 AI DevOps 编程智能体 - CodeRider-Kilo 正式发布!半臻(火白)19 小时前
Prompt-R1:重新定义AI交互的「精准沟通」范式菠菠萝宝19 小时前
【AI应用探索】-10- Cursor实战:小程序&APP - 下连线Insight19 小时前
架构调整后,蚂蚁继续死磕医疗健康“硬骨头”小和尚同志19 小时前
十月份 AI Coding 实践!Qoder、CC、Codex 还是 iflow?keke.shengfengpolang19 小时前
中专旅游管理专业职业发展指南:从入门到精通的成长路径Danceful_YJ20 小时前
35.微调BERTZPC821020 小时前
FPGA 部署ONNX