文書の過去の版を表示しています。
画像をnumpy配列に変換
以下のサイトのコードほとんどそのままです。
Python – NumPyで画像を配列として取得する
投稿者: edo1z 投稿日: 09/27/2015
https://endoyuta.com/2015/09/27/python-numpyで画像を配列として取得する/
1. cat.jpgの用意
2. Jupyter Notebookで以下のコードを入力
from PIL import Image import numpy as np # PILでcat.jpgを開いてグレースケール画像に変換し、NumPy配列に変換 im = np.array(Image.open('cat.jpg').convert('L')) print(im.shape, im.dtype) print(im)
コードを入力してから、Shift + Enterを押すと、以下のような結果になります。
参考文献
ど素人の私がこのコードを見つけるまでに、以下の3つの本の該当部分を繰り返し読みました。
<html>
<iframe style=“width:120px;height:240px;” marginwidth=“0” marginheight=“0” scrolling=“no” frameborder=“0” src=“rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=twosquirrel-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4873117585&linkId=5239e874ec4f1301cf95b0c8cfc497a3”></iframe>
<iframe style=“width:120px;height:240px;” marginwidth=“0” marginheight=“0” scrolling=“no” frameborder=“0” src=“rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=twosquirrel-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4274221075&linkId=a28404f93dce25380672e34e6da81cbf”></iframe>
<iframe style=“width:120px;height:240px;” marginwidth=“0” marginheight=“0” scrolling=“no” frameborder=“0” src=“rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=twosquirrel-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=487311778X&linkId=ee1b4d5d66ceabe44b7c1445e0846348”></iframe>
</html>
Python – NumPyで画像を配列として取得する
投稿者: edo1z 投稿日: 09/27/2015
https://endoyuta.com/2015/09/27/python-numpyで画像を配列として取得する/
行列による画像処理 基礎編&目次 ~Python画像処理の再発明家~
20170405
https://qiita.com/secang0/items/1229212a37d8c9922901
NumPyで画像処理
http://www.mwsoft.jp/programming/computer_vision_with_python/1_3_numpy.html
初めてのPython画像処理
https://qiita.com/uosansatox/items/4fa34e1d8d95d8783536
https://lp-tech.net/articles/DCw73
===== リンク =====
あ