import cv2
import numpy as np
img = cv2.imread('fj.png', 0)
# gamma函数用于降低图像深色对比,是图像曝光均衡
def adjust_gamma(image, gamma=1.0):
invGamma = 1.0/gamma
table = []
for i in range(256):
table.append(((i / 255.0) ** invGamma) * 255)
table = np.array(table).astype("uint8")
return cv2.LUT(image, table)
img_gamma = adjust_gamma(img, 2)
cv2.imshow('12', img)
cv2.imshow('13', img_gamma)
cv2.waitKey(0)
cv2.destroyAllWindows()
from PIL import Image
from PIL import ImageFilter
img = Image.open('img.jpg')
# img.show()
# # 灰度
# gray = img.convert("L")
# gray.show()
# 白色描边
# img = img.filter(ImageFilter.CONTOUR)
# 黑色描边
# img = img.filter(ImageFilter.FIND_EDGES)
# 雕刻
# img = img.filter(ImageFilter.EMBOSS)
# img.show()