edo1z blog

プログラミングなどに関するブログです

2015-09-27から1日間の記事一覧

Python - NumPyで画像を配列として取得する

from PIL import Image from numpy import * im = array(Image.open('img.jpg').convert('L')) print(im.shape, im.dtype) print(im) (533, 800) uint8 [[156 159 162 ..., 135 132 130] [156 155 155 ..., 133 132 133] [155 153 155 ..., 134 133 131] ...…

Python3 - Pillowの使い方

参考:Python3.3対応画像処理ライブラリ Pillow(PIL) の使い方 from PIL import Image import os file_name = 'img.jpg' #画像ファイル開く img = Image.open(file_name) #グレースケール変換 img_gray = img.convert('L') #リサイズ img_resize = img.resiz…

macでOpenCVを使う

インストール $ port install opencv Warning: port definitions are more than two weeks old, consider using selfupdate Error: Insufficient privileges to write to MacPorts install prefix. 参考:YosemiteでMacportsが動かない & cmakeがインストー…