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')
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')
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
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)
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')