您的位置:首页 > 其它

tensorflow实现图像色彩的调整

2017-05-24 19:57 295 查看
实现图像的调整包括以下几个方面:

调整图像的亮度:tf.image.adjust_brightness(img, p)。img是表示目标图像,p表示对比度,大于零变亮,反之变暗

调整图像的对比度。tf.image.adjust_contrast,用法同上

调整色相。tf.image.adjust_hue。用法同上

调整饱和度:tf.image.adjust_saturation。用法同上

例如:

import matplotlib.pyplot as plt;
import tensorflow as tf;

image_raw_data_jpg = tf.gfile.FastGFile('11.jpg', 'r').read()

with tf.Session() as sess:
img_data_jpg = tf.image.decode_jpeg(image_raw_data_jpg)
img_data_jpg = tf.image.convert_image_dtype(img_data_jpg, dtype=tf.float32)
img_1 = tf.image.adjust_brightness(img_data_jpg, 0.5)
img_2 = tf.image.adjust_contrast(img_data_jpg, 5)
img_3 = tf.image.adjust_hue(img_data_jpg, 0.8)
img_4 = tf.image.adjust_saturation(img_data_jpg, 5)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: