python cv之均值、高斯、中值、双边滤波
当我第一次看到这个代码就被征服了,太喜欢py封装了。
源代码,直接可运行那种哟~!!!
# _ * _ coding:utf-8 _ * _
import numpy as np
import cv2
import matplotlib.pyplot as plt
#cv2.namedWindow('input_image', cv2.WINDOW_AUTOSIZE)
imagepath = r'depth\color_depth.jpg'
image = cv2.imread(imagepath)
ret, thresh1 = cv2.threshold(image, 100, 210, cv2.THRESH_BINARY)
cv2.imshow('erz', thresh1)
#cv2.imshow('input', image)
#image=cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
#均值滤波
img_mean = cv2.blur(image, (5,5))
# 高斯滤波
img_Guassian = cv2.GaussianBlur(image,(3,3),0)
# 中值滤波
img_median = cv2.medianBlur(thresh1, 11)
# 双边滤波
img_bilater = cv2.bilateralFilter(image,5,15,15)
#dst = cv2.fastNlMeansDenoisingColored(image, None, 20, 20, 7, 21)
#cv2.imshow('out', img_mean)
#cv2.imshow('out1', img_Guassian)
cv2.imshow('out2', img_median)
#cv2.imshow('out3', img_bilater)
#cv2.imwrite('out.jpg', dst2)
cv2.waitKey(0)
直接运行,自己调调参,我相信一定可以得到你最想要的效果。
还是那句。。。。
要做一枚积极乐观的程序员呀~
nice!