示例#1
0
文件: test.py 项目: burk/inf4300
def calc_features(f1, f2):
    res = []
    feats = [f1, f2]
    quads = [(0, 0, 4, 4), (0, 4, 4, 8), (4, 4, 8, 8), (0, 8, 8, 16), (8, 8, 16, 16)]

    features = []
    for gin in [0, 1]:
        g = feats[gin]
        for quad in quads:
            m = glcm.quadrant(g, quad).flatten()
            features.append(m)
            
    features = np.array(features)
    res.append(features.transpose((1,0)))

    res = np.vstack(res)
    return res
示例#2
0
文件: test.py 项目: burk/inf4300
# Add padding
train1_pad = np.pad(mosaic1_train, 15, mode='reflect')

# Calculate GLCM matrices
g1 = glcm.fast_glcm(train1_pad, size=31, stride=1, levels=16, dx=1, dy=0)
g2 = glcm.fast_glcm(train1_pad, size=31, stride=1, levels=16, dx=0, dy=1)

# Calculate selected quadrant features
quads = [(0, 0, 4, 4), (0, 4, 4, 8), (4, 4, 8, 8), (0, 8, 8, 16), (8, 8, 16, 16)]
tit = ["Q_11", "Q_12", "Q_14", "Q_2", "Q_4"]
plt.figure(1, figsize=(20,20))
i = 0
for quad, t in zip(quads, tit):
    plt.subplot(1, len(quads), i+1)
    plt.imshow(glcm.quadrant(g1, quad))
    plt.title(t)
    i += 1

plt.show()

quads = [(0, 0, 4, 4), (0, 4, 4, 8), (4, 4, 8, 8), (0, 8, 8, 16), (8, 8, 16, 16)]
tit = ["Q_11", "Q_12", "Q_14", "Q_2", "Q_4"]
plt.figure(1, figsize=(20,20))
i = 0
for quad, t in zip(quads, tit):
    plt.subplot(1, len(quads), i+1)
    plt.imshow(glcm.quadrant(g2, quad))
    plt.title(t)
    i += 1