~/image/e6 で演習
# -*- coding: utf-8 -*- # e601.py import Image from Pycluster import * import ClusterImg img = Image.open('1.ppm') width , height = img.size data = list(img.getdata()) # kcluster をデフォルト設定で使用 N = 10 clusterid, error, nfound = kcluster(data, N) # 後処理と表示 clustavr = ClusterImg.calcavr(clusterid, img, N) print clustavr cimg = ClusterImg.clusterimg(img.size, clusterid, clustavr) cimg.show()
imx = img.convert('L') imx = imx.filter(ImageFilter.FIND_EDGES) imx = imx.filter(ImageFilter.SMOOTH_MORE) # imx.show() data = scipy.transpose(scipy.array([list(imx.getdata())])) data = scipy.concatenate((scipy.array(img.getdata()), data), 1)
e602.py
で作成、結果は e602.ppm
に保存。uv = [] for x in data: r, g, b = x u = -0.14713 * r - 0.28886 * g + 0.436 * b v = 0.615 * r - 0.51499 * g - 0.10001 * b uv.append((u, v))
e603.py
で作成、結果は e603.ppm
に保存。