[英]How to increase the size of image using python?
我有大小為48x48
的圖像。 我想將其大小增加到150x150
以使用遷移學習(CNN)進行訓練。 有什么可能的方法來做到這一點? 我想以這樣的方式增加圖像大小,使分辨率保持不變而不會丟失任何數據。
您可以毫無問題地使用tensorflow.image.resize
方法
tf.image.resize(X, [150, 150])
如果您閱讀 tensorflow 的文檔,它指出您可以使用不同的方法進行下采樣和上采樣
method 參數需要來自 image.ResizeMethod 枚舉的項目,或等效的字符串。 選項包括:
這可能會奏效。
from PIL import Image
import numpy as np
# random image data
image_data = np.random.randint(low=0, high=256, size=(48,48,3)).astype(np.uint8)
image_small = Image.fromarray(image_data)
# there are many settings you can play here, depending on how you want the image resized
image_large = image_small.resize((120,120))
np.array(image_large)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.