Tensorflow中图像处理函数

来源:互联网 发布:java交换两个数 编辑:程序博客网 时间:2024/05/22 02:15

图像色调调整:

调整图像亮度函数:tf.image.adjust_brightness(img_data,R)     R为调整亮度的参数

                                    tf.image.random_brightness(image,max_delta)  #在[-max_delta,max_delta]的范围随机调整图像的亮度;

调整图像的对比度函数:tf.image.adjust_contrast(img_data,R)  #R为调整对比度的参数;

                                            tf.image.random_constrast(image,lower,upper) # 在[lower,upper]的范围随机调整图的对比度;

调整图像的色相函数:tf.image.adjust_hue(img_data,R) #R为调整色相的参数值

                                        tf.image.random_hue(image,max_delta) #max_delta的取值在[0,0.5]之间;

调整图像的饱和度函数:tf.image.adjust_saturation(img_data,R)

                                             tf.image.random_saturation(image, lowet, upper)  #在[lower,upper]的范围随机调整图的饱和度;

图像标准化操作:将图像上的亮度均值设置为0,方差设置为1;

                                         tf.image.per_image_whitening(img_data)


处理标注框:tf.image.draw_bounding_boses函数;

img_data = tf.image.resize_images(img_data, 180, 267, method=1)                  #先设定图像的大小                                                                batched = tf.expand_dims(tf.image.convert_image_dtype(img_data,tf.float32),0)   #将图像矩阵转化为实数类型                                                    boxes = tf.image.draw_bounding_boxes([[[0.05,0.05,0.9,0.7],[0.35,0.47,0.5,0.56]]])                                                                           result = tf.image.draw_bounding_boxes(batched,boxes)
通过tf.image.sample_distorted_bounding_box函数实现随机截取图像;