在我看來,圖像標準化是使每個像素都被標準化爲一個介於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.')
標準化可能意味着很多事情。提示:爲什麼不是-0.5到0.5? – kazemakase
對!但有什麼區別? – WeiJay
它看起來像這個代碼它是一些超/多光譜成像的一部分。對於這些技術,這不是進行標準化的方法。代碼所做的只是將一些pixcel轉換成一個數據立方體,並將它們從8位圖像轉換爲一個64/32位浮點數組,位於-0.5和0.5之間。還有,它會檢查分辨率是否相同。 –