美文网首页
2018-08-13 image data processng

2018-08-13 image data processng

作者: 镜中无我 | 来源:发表于2019-02-18 17:15 被阅读4次

    pretreatment

    TFRecord

    input data format
    Example{Features{map<String,Feature{BytesList or FloatList or Int64List}>}}
    write

    • step1: setup a writer with filename for TFRecord
    • step2: get the images data ,labels data ,and etc.
    • step3: piecewise transformation{
      setup a example with image-concerned data
      write its serialized sequence into writer
      }
      read
    • step1: setup a reader with filepath
    • step2: read the serialized example
    • step3: parse_single_example(serialized_example,features={'': tf.FixedLenFeature([],tf.dtype,...)})
    • step4: images= tf.decode_raw(features['image_raw'], tf.uint8)
      other cast(features,dtype)
    • step5: multi threads for processing
    image processing functions
    • encoding
      objects: jpeg png
    image_raw_data=tf.gfile.FastGFile('image_path','r').read()
    with tf.session() as sess:
           img_data=tf.image.decode_jpeg(image_raw_data)
           print(img_data.eval())
           plt.imshow(img_data.eval())
           plt.show()
           img_data=tf.image_convert_iamge_dtype(img_data,dtype=tf.float32)
    #encode 
    
    • scale adjustment
      tf.image.resize_images(img_data, 300,300,method=0)
      method:
      method value algorithms
      0 Bilinear interpolation
      1 Nearest neighbor interpolation
      2 Bicubic interpolation
      3 Area interpolation

    tf.image.resize_image_with_crop_or_pad(img_data, len_scale,wid_scale)
    tf.image.central_crop(img_data,proportion)
    tf.image.flip_up_down(...)#left_right
    tf.image.transpose_image(image_data)
    tf.image.random_flip_...

    • color
      tf.image.adjust_brightness(img_data,-0.5)
      tf.image.random_brightness(img_data,max_delta)
      tf.image.adjust_contrast(img_data,-5)
      tf.image.random_contrast(...,lower,upper)
      tf.image.adjust_hue(image_data,)#0.1,0.3,0.6,0.9
      tf.image.random_hue(,max_delta)
      tf.image.adjust_saturation(...,...,...)
      tf.image.per_image_whitening(...)#standardize the image
    • marking frame
      tf.image.draw_bounding_boxes(img_data,coordinates of boxes)

    相关文章

      网友评论

          本文标题:2018-08-13 image data processng

          本文链接:https://www.haomeiwen.com/subject/zsrybftx.html