22 lines
836 B
Python
22 lines
836 B
Python
import numpy as np
|
||
import cv2
|
||
from scipy import ndimage
|
||
|
||
#一个3*3的卷积核,如果一个像素比他周围的像素更加突出,就会提升其本身的亮度
|
||
kernel133=np.array([[-1,-1,-1],
|
||
[-1,-8,-1],
|
||
[-1,-1,-1]])
|
||
|
||
#一个3*3的卷积核,如果一个像素比他周围的像素更加昏暗,就会更进一步减少其本身的亮度
|
||
kernel133_D=np.array([[1,1,1],
|
||
[1,-8,1],
|
||
[1,1,1]])
|
||
|
||
img=cv2.imread("lana.jpg",0)
|
||
#ndimage是一个处理多维图像的函数库,他可以用于图像滤波器,傅里叶变换,图像的旋转拉伸以及测量和形态学处理
|
||
linghtImg=ndimage.convolve(img,kernel133_D)
|
||
blurred=cv2.GaussianBlur(img,(11,11),0)
|
||
gaussImg=img-blurred
|
||
cv2.imshow("img",linghtImg)
|
||
cv2.imshow("img1",gaussImg)
|
||
cv2.waitKey(0) |