图像归一化

Image normalization

在我看来,图像归一化就是让每个像素都归一化为0到1之间的值,对吗?

但是下面的代码是什么意思呢?

image_size = 28      # Pixel width and height.
pixel_depth = 255.0  # Number of levels per pixel.

for image in image_files:
  image_file = os.path.join(folder, image)

  try:
    image_data = (ndimage.imread(image_file).astype(float) - 
                pixel_depth / 2) / pixel_depth  # WHY ??
    if image_data.shape != (image_size, image_size):
      raise Exception('Unexpected image shape: %s' % str(image_data.shape))
    dataset[num_images, :, :] = image_data
    num_images = num_images + 1

  except IOError as e:
    print('Could not read:', image_file, ':', e, '- it\'s ok, skipping.')

Image normalization只是改变像素强度值范围的过程。

新范围的选择由您决定。

在您显示的情况下,似乎已选择范围 -0.5 .. 0.5。