# -*- coding:utf-8 -*-
import tensorflow as tf
import numpy as np
import cv2
seed=1
img = cv2.imread('000001.png')
img_dis = cv2.imread('000001_dis.png')
img_tf = tf.convert_to_tensor(img) # [960,540,3]
img_dis_tf = tf.convert_to_tensor(img_dis) # [960,540,3]
distorted_image = tf.random_crop(img_tf, [256, 512, 3],seed=seed) # [256,512,3]
disp_image = tf.random_crop(img_dis_tf, [256, 512, 3],seed=seed) # [256,512,3]
//取通道
image1=distorted_image[:,:,0:3]#取distorted_image图片的三个通道,大小都是,256×512
with tf.Session() as sess2:
sess2.run(tf.global_variables_initializer())
img,img2_tf_numpy_dis,image111 = sess2.run([distorted_image,disp_image,image1])
# 显示随机裁剪后的图片
cv2.imshow('random_crop_image', img)
cv2.imshow('random_crop_image_dis', img2_tf_numpy_dis)
cv2.imshow('iamge11', image111)
cv2.waitKey(0)
image11,便是从distorted_image图片取的三个通道
联系客服