top of page

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



 
 
 

最新記事

すべて表示
PythonでYAHOO検索もスクレイピング

前回Google検索結果のTOP100取ったのでYAHOOも追加。 YAHOOは10件ずつしか取れないので注意! #!/usr/bin/env python3 # -*- coding: utf-8 -*- # 指定のURLをブラウザで開く #...

 
 
 

Comments


記事: Blog2_Post

©2021 by 日々Python。Wix.com で作成されました。

bottom of page