与matlab里面 imcomplement 函数(负片函数)相同的python代码

import cv2
import numpy as np

def imcomplement(img):  # 负片函数,相当于对图片取反 0<->255, 10<->245, 21<->234
    table = np.array([255 - i for i in np.arange(0, 256)]).astype("uint8")
    return cv2.LUT(img, table)  # 使用OpenCV的查找表函数

        输入时一个灰度图片,每个像素点的灰度值取了个反(0<->255, 10<->245, 21<->234)这种类型的取反

posted on 2021-06-12 09:50  雾恋过往  阅读(111)  评论(0编辑  收藏  举报

Live2D