我正在使用一组32x32x32的灰度图像,希望在使用tflearn + tensorflow训练CNN时将随机旋转应用于图像以进行数据增强。我使用以下代码来执行此操作:
# Real-time data preprocessing
img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()
# Real-time data augmentation
img_aug = ImageAugmentation()
img_aug.add_random_rotation(max_angle=360.)
# Input data
with tf.name_scope('Input'):
X = tf.placeholder(tf.float32, shape=(None, image_size,
image_size, image_size, num_channels), name='x-input')
Y = tf.placeholder(tf.float32, shape=(None, label_cnt), name='y-input')
# Convolutional network building
network = input_data(shape=[None, 32, 32, 32, 1],
placeholder = X,
data_preprocessing=img_prep,
data_augmentation=img_aug)
(I'm using a combination of TensorFlow and TFLearn to leverage features from both. Please let me know if there are any issues with my placeholder usage. Keep HTML tags intact.)
I have discovered that using the add_random_rotation function (which employs scipy.ndimage.interpolation.rotate) treats the third dimension of my grayscale images as channels, similar to RGB channels. It randomly rotates all 32 images of the third dimension by a random angle around the z-axis (treating my 3D image like a 2D image with 32 channels). However, I want the image to be rotated in space (around all three axes). Do you know of any functions or packages that can easily rotate 3D images in space?
axes=(1,2)
是否等同于axes=(2,1)
? - Tin