Ejemplo n.º 1
0
def test_SavitzkyGolay(n_clusters, data, result_path):
    print('Testing SavitzkyGolay bands filter')

    tdata = SavitzkyGolay_bands_filter(data, result_path)
    km = skl.KMeans()
    km.predict(tdata, n_clusters)
    km.plot(result_path, colorMap='jet', suffix='SG_bands_filter')

    tdata = SavitzkyGolay_spectra_filter(data, result_path)
    km = skl.KMeans()
    km.predict(tdata, n_clusters)
    km.plot(result_path, colorMap='jet', suffix='SG_spectra_filter')
Ejemplo n.º 2
0
def test_MNF(n_clusters, n_components, data, result_path):
    print('Testing MNF')
    tdata = MNF(data, n_components, result_path)
    km = skl.KMeans()
    km.predict(tdata, n_clusters)
    km.plot(result_path, colorMap='jet', suffix='MNF')

    print('Testing MNF with component 2 noise reduction')
    idata = MNF_reduce_component_2_noise_and_invert(data)
    km = skl.KMeans()
    km.predict(idata, n_clusters)
    km.plot(result_path,
            colorMap='jet',
            suffix='MNF_with_component_2_noise_reduction')
Ejemplo n.º 3
0
def kmeans_pysp(img):
    time1 = timer()
    with warnings.catch_warnings():
        warnings.simplefilter('ignore', category=FutureWarning)
        km = skl.KMeans()
        m = km.predict(img, n_clusters=3, n_jobs=-1)  # n_jobs = #CPUs
        time2 = timer()
        print('kmeans time: ', time2 - time1)
        return m
Ejemplo n.º 4
0
def tests():
    data_path = os.environ['PYSPTOOLS_DATA']
    home = os.environ['HOME']
    result_path = osp.join(home, 'results')
    if osp.exists(result_path) == False:
        os.makedirs(result_path)

    sample = '92AV3C.hdr'

    data_file = osp.join(data_path, sample)
    data, header = util.load_ENVI_file(data_file)

    n_clusters = 5
    km = skl.KMeans()
    km.predict(data, n_clusters)
    km.plot(result_path, colorMap='jet', suffix='data')

    n_components = 40
    test_MNF(n_clusters, n_components, data, result_path)
    test_whiten(n_clusters, data, result_path)
    test_SavitzkyGolay(n_clusters, data, result_path)
Ejemplo n.º 5
0
def test_whiten(n_clusters, data, result_path):
    print('Testing whiten')
    wdata = whiten(data)
    km = skl.KMeans()
    km.predict(wdata, n_clusters)
    km.plot(result_path, colorMap='jet', suffix='whiten')