锚点就是卷积核所对应的图像中间的点,比方说是3x3的卷积核,那对应的锚点可以是16
低通滤波:低于某个阀值滤波可以通过
高通滤波:高于某个阀值滤波可以通过
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('E://pic//10.jpg')
kernel = np.ones((5, 5), np.float32) / 25
dst = cv2.filter2D(img, -1, kernel)
cv2.imshow('dst', dst)
cv2.imshow('img', img)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('E://pic//10.jpg')
# kernel = np.ones((5, 5), np.float32) / 25
# dst = cv2.filter2D(img, -1, kernel)
dst = cv2.blur(img, (5, 5))
cv2.imshow('dst', dst)
cv2.imshow('img', img)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./gaussian.png')
# kernel = np.ones((5, 5), np.float32) / 25
# dst = cv2.filter2D(img, -1, kernel)
dst = cv2.GaussianBlur(img, (5, 5), sigmaX=1)
cv2.imshow('dst', dst)
cv2.imshow('img', img)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./papper.png')
# kernel = np.ones((5, 5), np.float32) / 25
# dst = cv2.filter2D(img, -1, kernel)
dst = cv2.medianBlur(img, 5)
cv2.imshow('dst', dst)
cv2.imshow('img', img)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./bieber.jpeg')
# kernel = np.ones((5, 5), np.float32) / 25
# dst = cv2.filter2D(img, -1, kernel)
# dst = cv2.medianBlur(img, 5)
dst = cv2.bilateralFilter(img, 7, 20, 50)
cv2.imshow('dst', dst)
cv2.imshow('img', img)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./chess.png')
# 索贝尔算子y方向边缘
d1 = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=5)
# 索贝尔算子x方向边缘
d2 = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5)
# dst = d1 + d2
dst = cv2.add(d1, d2)
cv2.imshow('img', img)
cv2.imshow('d1', d1)
cv2.imshow('d2', d2)
cv2.imshow('dst', dst)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./chess.png')
# 索贝尔算子y方向边缘
# d1 = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=5)
d1 = cv2.Scharr(img, cv2.CV_64F, 1, 0)
# 索贝尔算子x方向边缘
# d2 = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5)
d2 = cv2.Scharr(img, cv2.CV_64F, 0, 1)
# dst = d1 + d2
dst = cv2.add(d1, d2)
cv2.imshow('img', img)
cv2.imshow('d1', d1)
cv2.imshow('d2', d2)
cv2.imshow('dst', dst)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./chess.png')
# 索贝尔算子y方向边缘
# d1 = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=5)
# 沙尔算子
# d1 = cv2.Scharr(img, cv2.CV_64F, 1, 0)
# 索贝尔算子x方向边缘
# d2 = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=5)
# 沙尔算子
# d2 = cv2.Scharr(img, cv2.CV_64F, 0, 1)
# dst = d1 + d2
# dst = cv2.add(d1, d2)
# 拉普拉斯
ldst = cv2.Laplacian(img, cv2.CV_64F, ksize=5)
cv2.imshow('img', img)
# cv2.imshow('d1', d1)
# cv2.imshow('d2', d2)
cv2.imshow('dst', ldst)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
超过最大值肯定是边缘,低于最小值肯定不是边缘,而介于最大值和最小值之间,如果和超出最大值A是连续的,则C也是边缘,而B就不是边缘
# -*- coding: utf-8 -*-
import cv2
import numpy as np
img = cv2.imread('./lena.png')
dst = cv2.Canny(img, 100, 200)
cv2.imshow("img", img)
cv2.imshow("dst", dst)
key = cv2.waitKey(0) & 0xff
if key == ord('q'):
cv2.destroyAllWindows()
之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!