본문 바로가기

Deep Learning

[image pre-processing] image normalization

반응형
def image_normalization(image_batch, batch_size):

for i in range(0, batch_size):
# get i-th image from the input mini-batch
tmp = image_batch[i, :, :, :]

# calculate std and mean of the image
std = np.sqrt(np.var(tmp.astype("float32"))) + 0.00000001
mean = np.mean(tmp.astype("float32"))

# normalization
image_batch[i, :, :, :] = (tmp.astype("float32") - mean) / std

return image_batch