Page 202 - python
P. 202
176
ภาพประกอบที่ 12.15 แสดงภาพภูเขาและทะเลเพื่อใชทํานายผลจากโมเดลที่สรางขึ้น
ื
ตัวอยางที่ 12.15 การสรางโมเดลเพอพยากรณภาพภูเขาหรือทะเล
่
%pylab inline
import mahotas as mh
features = []
labels = []
img = mh.imread("sea1.jpg")
img = mh.colors.rgb2gray(img, dtype=np.uint8)
features.append(mh.features.haralick(img).ravel())
img = mh.imread("sea2.jpg")
img = mh.colors.rgb2gray(img, dtype=np.uint8)
features.append(mh.features.haralick(img).ravel())
img = mh.imread("sea3.jpg")
img = mh.colors.rgb2gray(img, dtype=np.uint8)
features.append(mh.features.haralick(img).ravel())
img = mh.imread("sea4.jpg")
img = mh.colors.rgb2gray(img, dtype=np.uint8)
features.append(mh.features.haralick(img).ravel())
img = mh.imread("sea5.jpg")
img = mh.colors.rgb2gray(img, dtype=np.uint8)
features.append(mh.features.haralick(img).ravel())
img = mh.imread("mountain1.jpg")
img = mh.colors.rgb2gray(img, dtype=np.uint8)
features.append(mh.features.haralick(img).ravel())