tf.image.adjust_brightness等的使用

import tensorflow as tf
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
sess=tf.Session()
name='../main/0.jpg' # 相对位置
img=tf.read_file(name) # 用tf读取图像
img=tf.image.decode_image(img) # 因为读取图片为字符需要解码
img_shape=sess.run(img) # 只有运行了命令就可以得到图片数据
img_shape=img_shape.shape # 得到图像形状
img_sha=tf.reshape(img,[1,img_shape[0],img_shape[1],img_shape[2]]) # 对比度函数tf.image.adjust_brightness是批量的,因为tf解决批量处理的
new_img=tf.image.adjust_brightness(img_sha,0.5)   # 0.5 将对比度增强0.5倍 若为-0.5将对比度减弱0.5倍
new_img=sess.run(new_img)
new_img=new_img.reshape((img_shape[0],img_shape[1],img_shape[2]))
new_img=np.array(new_img,np.uint8)


cv.imshow('dd',new_img)
cv.waitKey()
原文地址:https://www.cnblogs.com/tangjunjun/p/11817095.html