如何在CIFAR10中加白图像?

时间:2019-04-22 08:12:31

标签: python tensorflow image-processing conv-neural-network image-whitening

我正在处理CIFAR10数据集,我想加白特定的图像并显示结果。但是经过很多尝试,我无法这样做。有人可以告诉我该怎么做吗?

我尝试使用tf.image.per_image_standardization(),但对图像完全没有影响。这是我的代码:

def load_cfar10_batch(path):
    with open(path + '/data_batch_1', mode='rb') as file:
        batch = pickle.load(file, encoding='latin1')   

    features = batch['data']
    labels = batch['labels']

    return features, labels

features,labels = load_cfar10_batch(path)

x = features.reshape((len(features), 3, 32, 32)).transpose(0, 2, 3, 1)
x.shape

plt.imshow(x[9999])

y = labels
def one_hot_encode(y):
    encoded = np.zeros((len(y), 10))
    for index, val in enumerate(y):
        encoded[index][val] = 1
    return encoded

def normalize(x):
    x_norm = x/255
    return x_norm


whitened_image = tf.image.per_image_standardization(x[9999])
plt.imshow(x[9999]) #showing no change

0 个答案:

没有答案