TIFファイルの読み込み
- hiro2studio
- 2021年1月25日
- 読了時間: 1分
TIF取得のクラスです。
結果は2Dのnumpy配列になります。
class data_get:
def __init__(self):
return
"""
(Purpose)
tiffファイルからデータ部分を抜き出す
in :filename 入力ファイルパス
out:outdata 出力配列(2次元のnumpy)
(History)
2017/11/30 作成
"""
def get_tiff_data(self, filename):
# 拡張子確認
root, ext = os.path.splitext(filename)
if ext in ['.tif','.tiff']:
# TIFFファイル取り込み 配列化
img = Image.open(filename)
ar_width, ar_height = img.size
outdata = img.getdata()
outdata = numpy.reshape(outdata, (ar_height, ar_width))
else:
return None
return outdata
Comments