コード例 #1
0
def class_labels(path, data):
    r = util.ROIs(data.shape[0], data.shape[1])
    r.add('Alfalfa', {'poly': ((67, 98), (73, 98), (75, 101), (70, 101))})
    r.add('Corn-notill', {'rec': (33, 31, 41, 56)})
    r.add('Corn-min', {'rec': (63, 6, 71, 21)}, {'rec': (128, 20, 134, 46)})
    r.add(
        'Corn', {
            'poly': ((35, 7), (35, 5), (48, 10), (48, 23), (45, 22), (44, 16),
                     (35, 10), (35, 5))
        })
    r.add('Grass/Pasture', {'rec': (75, 4, 85, 21)})
    r.add('Grass/Trees', {'rec': (48, 28, 70, 35)})
    r.add('Grass/pasture-mowed', {'rec': (73, 109, 78, 112)})
    r.add('Hay-windrowed', {'rec': (39, 124, 59, 138)})
    r.add('Soybeans-notill', {'rec': (42, 78, 63, 92)})
    r.add('Soybean-min-till', {'rec': (78, 34, 111, 45)},
          {'rec': (3, 112, 17, 117)}, {'rec': (80, 51, 95, 71)})
    r.add('Soybean-clean', {'rec': (52, 5, 58, 24)})
    r.add('Wheat', {'rec': (119, 26, 124, 46)})
    r.add('Woods', {'rec': (121, 91, 137, 121)})
    r.add('Stone-steel towers',
          {'poly': ((14, 47), (23, 44), (24, 49), (16, 52), (14, 47))})

    # These one don't perform well
    #r.add('Oats', {'rec': (63,23,71,24)})
    #r.add('Bldg-Grass-Tree-Drives', {'rec': (18,27,27,34)})

    r.plot(path, colorMap='Paired')
    return r
コード例 #2
0
ファイル: test_SVC.py プロジェクト: sebastiani/pysptools
def test_SVC(data, result_path):
    r = util.ROIs(data.shape[0], data.shape[1])
    r.add('Alfalfa', {'poly': ((67, 98), (73, 98), (75, 101), (70, 101))})
    r.add('Corn-notill', {'rec': (33, 31, 41, 56)})
    r.add('Corn-min', {'rec': (63, 6, 71, 21)}, {'rec': (128, 20, 134, 46)})
    r.add(
        'Corn', {
            'poly': ((35, 7), (35, 5), (48, 10), (48, 23), (45, 22), (44, 16),
                     (35, 10), (35, 5))
        })
    r.add('Grass/Pasture', {'rec': (75, 4, 85, 21)})
    r.add('Grass/Trees', {'rec': (48, 28, 70, 35)})
    r.add('Grass/pasture-mowed', {'rec': (73, 109, 78, 112)})
    r.add('Hay-windrowed', {'rec': (39, 124, 59, 138)})
    r.add('Soybeans-notill', {'rec': (42, 78, 63, 92)})
    r.add('Soybean-min-till', {'rec': (78, 34, 111, 45)},
          {'rec': (3, 112, 17, 117)}, {'rec': (80, 51, 95, 71)})
    r.add('Soybean-clean', {'rec': (52, 5, 58, 24)})
    r.add('Wheat', {'rec': (119, 26, 124, 46)})
    r.add('Woods', {'rec': (121, 91, 137, 121)})
    r.add('Stone-steel towers',
          {'poly': ((14, 47), (23, 44), (24, 49), (16, 52), (14, 47))})

    # These one don't perform well
    #r.add('Oats', {'rec': (63,23,71,24)})
    #r.add('Bldg-Grass-Tree-Drives', {'rec': (18,27,27,34)})

    r.plot(result_path, colorMap='Paired')

    svm = cls.SVC()
    #svm.fit(data, r, class_weight={0:1,1:10})
    svm.fit(data,
            r,
            class_weight={
                0: 1,
                1: 10,
                2: 10,
                3: 10,
                4: 10,
                5: 10,
                6: 10,
                7: 10,
                8: 10,
                9: 10,
                10: 10,
                11: 10,
                12: 10,
                13: 10,
                14: 10
            })
    svm.classify(data)
    #    svm.plot(result_path, labels=r.get_labels(), colorMap='Paired')
    svm.plot(result_path,
             labels=r.get_labels(),
             interpolation=None,
             colorMap='Paired')
コード例 #3
0
def concat_ROIs(rpath, data, coords, label, display=False):
    r = util.ROIs(data.shape[0], data.shape[1])
    for coord in coords:
        r.add(*coord)
    if display == True:
        if rpath == None:
            r.display(colorMap='Paired', suffix=' ' + label + ' cluster')
        else:
            r.plot(rpath, colorMap='Paired', suffix=' ' + label + ' cluster')
    return r
コード例 #4
0
def ROI(data, path):
    r = util.ROIs(data.shape[0], data.shape[1])
    r.add('Area', {'rec': (30, 30, 100, 100)})
    r.plot(path)
    return r
コード例 #5
0
ファイル: test_eea.py プロジェクト: wubizhi/pysptools
def ROI(data, path):
    r = util.ROIs(data.shape[0], data.shape[1])
    # Some roi
    r.add('Area', {'rec': (30,30,100,100)})
    r.plot(path, colorMap='Accent')
    return r
コード例 #6
0
 def put2(self, M, mp1, t1, mp2, t2):
     self.mask = np.logical_or((mp1 > t1), (mp2 > t2))
     self.roi = util.ROIs(M.shape[0], M.shape[1])
     self.roi.add(self.label, {'raw': self.mask})
コード例 #7
0
 def put1(self, M, mp1, t1):
     self.mask = mp1 > t1
     self.roi = util.ROIs(M.shape[0], M.shape[1])
     self.roi.add(self.label, {'raw': self.mask})
コード例 #8
0
 def _train_section(self, cube_section, mask_section, params, feature_name):
     roi = util.ROIs(cube_section.shape[0], cube_section.shape[1])
     roi.add(feature_name, {'raw': mask_section})
     model = self.estimator(**params)
     model.fit_rois(cube_section, roi)
     return model
コード例 #9
0
def _make_ROI(data, coords):
    r = util.ROIs(data.shape[0], data.shape[1])
    for coord in coords:
        r.add(*coord)
    return r