[英]Processing an Image using Tensorflow
我有 15 张图像存储在本地。 如何使用 tensorflow 将这些图像转换为数组以进行 CNN 类型的分类?
将图像转换为 numpy 数组格式
import cv2
im = cv2.imread("some_image.tiff")
将它们重塑为任意但相同的大小
def reshape(image_array):
return np.reshape(image_array, [128, 128, 3])
将它们全部放在一个列表中,然后使用以下方法对它们进行标准化,以便它们都具有标准化的像素值:
def per_image_standardization(arrays):
sess = tf.InteractiveSession()
standardized_tensors = tf.map_fn(lambda array:
tf.image.per_image_standardization(array),
arrays)
standardized_images = standardized_tensors.eval()
return standardized_images
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.