I've a 15 images which are stored locally. How do I transform these images to a array using tensorflow for a CNN type of Classification?
Convert the image to numpy array format
import cv2
im = cv2.imread("some_image.tiff")
Reshape them to an arbitrary, but identical, size
def reshape(image_array):
return np.reshape(image_array, [128, 128, 3])
Put them all in a list and then standardize them so they all have standardized pixel values using:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.