gamma 图像校正

在这里插入图片描述

dir_path='/Users/x x x x/Downloads/picture/IMG_4470.JPG'
image=cv2.imread(dir_path)
def gamma_trans(img,gamma):
    gamma_table=[np.power(x/255.0,gamma)*255 for x in range(256)] 
    #np.power(10,2)-->100 np.power(10,3)-->1000
    gamma_table=np.round(np.array(gamma_table)).astype(np.uint8) 
    # np.round(9.8)-->10.0  np.round(9.4)-->9.0
    return cv2.LUT(img,gamma_table) #v2.LUT 
image_gamma_1=gamma_trans(image,2.2)
image_gamma_2=gamma_trans(image,0.8)
cv2.imshow('image',image)
cv2.imshow('image_gamma_1',image_gamma_1)
cv2.imshow('image_gamma_2',image_gamma_2)
cv2.imwrite('gamma_1.png',image_gamma_1)
cv2.imwrite('gamma_2.png',image_gamma_2)

cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.waitKey(1)

原图:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值