# p = p+40 # p = p*1.2+40 import cv2 import numpy as np img = cv2.imread('image0.jpg',1) imgInfo = img.shape height = imgInfo[0] width = imgInfo[1] cv2.imshow('src',img) dst = np.zeros((height,width,3),np.uint8) for i in range(0,height): for j in range(0,width): (b,g,r) = img[i,j] # 把图片读取进来,放到(b,g,r)中。通过i和j的下标来完成图片读取。 bb = int(b*1.3)+40 gg = int(g*1.2)+40 #rr = int(r)+40 if bb>255: bb = 255 if gg>255: gg = 255 #if rr>255: #rr = 255 #dst[i,j] = (bb,gg,rr) dst[i,j] = (bb,gg,r) cv2.imshow('dst',dst) cv2.waitKey(0)
既然是双边滤波器,就说明有两个滤波的内核,一个滤出我们的噪声,另外一个保存我们的细节。这些参数要结合着我们当前双边滤波器它的算法原理以及它的滤波核来进行讲解。
#双边滤波 import cv2 img = cv2.imread('1.jpg',1) cv2.imshow('src',img) dst = cv2.bilateralFilter(img,15,35,35) cv2.imshow('dst',dst) cv2.waitKey(0)