TShopping

標題: python uint8作用為何 [打印本頁]

作者: woff    時間: 2021-3-2 19:43
標題: python uint8作用為何
代碼如下:
  1. import numpy as np
  2. x = np.array([1.43,288.3,-5.6,10.5,255,256])
  3. print(x)
  4. print(x.dtype)
  5. print('熱數值資料想要轉換成圖像,直必須介於0-255間')
  6. y =x.astype('uint8')
  7. print(y)
  8. print(y.dtype)
複製代碼
結果如下圖



小數點先捨去,超過255就相減或相加





歡迎光臨 TShopping (http://www.tshopping.com.tw/) Powered by Discuz! X3.2