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())
   197   198   199   200   201   202   203   204   205   206