【594】圖像讀取與顯示(mask圖像)

  圖像轉數組

from keras.preprocessing import image 
img_path = target_img_paths[9]
img = image.load_img(img_path)
x = image.img_to_array(img)

x.shape 

# (448, 500, 3)

# 獲取數組包含的值,三個通道的值一樣
set(x.reshape(448*500*3))

# {1.0, 2.0, 3.0}

  只包含幾個數值的圖像顯示

from IPython.display import Image, display
from tensorflow.keras.preprocessing.image import load_img
import PIL
from PIL import ImageOps

# Display input image #7
# 正常圖片顯示
display(Image(filename=input_img_paths[9]))

# Display auto-contrast version of corresponding target (per-pixel categories)
# 只含有 3 個數字的圖像顯示
img = PIL.ImageOps.autocontrast(load_img(target_img_paths[9]))
display(img)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章