def tests(): import pysptools.util as util 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) axes = parse_ENVI_header(sample, header) U = NFINDR(data, axes, result_path) r = ROI(data, result_path) test_SID(data, U, r, result_path) test_SAM(data, U, r, result_path) test_NormXCorr(data, U, r, result_path) test_SID_single(data, U, result_path) test_SAM_single(data, U, result_path) test_NormXCorr_single(data, U, result_path) test_AbundanceClassification(data, result_path) test_one_spectrum(data, U, r, result_path)
def tests(): import pysptools.util as util 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) axes = parse_ENVI_header(sample, header) U = NFINDR(data, axes, result_path) r = ROI(data, result_path) test_SID(data, U, r, result_path) test_SAM(data, U, r, result_path) test_NormXCorr(data, U, r, result_path) test_SID_single(data, U, result_path) test_SAM_single(data, U, result_path) test_NormXCorr_single(data, U, result_path) test_AbundanceClassification(data, result_path) test_one_spectrum(data, U, result_path)
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) # load the cube sample = 'samson_part.hdr' data_file = osp.join(data_path, sample) data, header = util.load_ENVI_file(data_file) # load the spectrum to detect to_detect_hdr_name = 'white_roof.hdr' y = load_signal_to_detect(data_path, to_detect_hdr_name) # load some background pixels needed by OSP background = 'bground1.hdr' lib_file = osp.join(data_path, background) U, info = util.load_ENVI_spec_lib(lib_file) test_MatchedFilter(data, y, result_path) test_ACE(data, y, result_path) test_CEM(data, y, result_path) test_GLRT(data, y, result_path) test_OSP(data, U, y, result_path)
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) data = remove_bands(data) test_SVC(data, result_path)
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) test_hysime(data) test_HfcVd(data) test_synthetic_hypercube('ENVI')
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) #data = np.fliplr(data) km = cls.KMeans() km.predict(data, 5) km.plot(result_path, colorMap='jet')
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) data = remove_bands(data) rois = class_labels(result_path, data) test_HyperSVC(result_path, data, rois) test_HyperGaussianNB(result_path, data, rois) test_HyperKNeighborsClassifier(result_path, data, rois) test_HyperLogisticRegression(result_path, data, rois) test_HyperRandomForestClassifier(result_path, data, rois)
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) axes = parse_ENVI_header(sample, header) roi = ROI(data, result_path) m = roi.get_mask() test_PPI(data, axes, m, result_path) test_ATGP(data, axes, m, result_path) test_FIPPI(data, axes, m, result_path) test_NFINDR(data, axes, m, result_path)
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 = cls.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 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)
plt.colorbar() fout = osp.join(path, 'plot_{0}.png'.format(desc)) plt.savefig(fout) plt.clf() if __name__ == '__main__': # Load the cube data_path = os.environ['PYSPTOOLS_DATA'] home = os.environ['HOME'] result_path = os.path.join(home, 'results') sample = 'hematite.hdr' data_file = osp.join(data_path, sample) data, header = util.load_ENVI_file(data_file) if osp.exists(result_path) == False: os.makedirs(result_path) axes = parse_ENVI_header(header) # Telops cubes are flipped left-right # Flipping them again restore the orientation data = np.fliplr(data) U = get_endmembers(data, axes, 4, result_path) amaps = gen_abundance_maps(data, U, result_path) # EM4 == quartz quartz = amaps[:,:,3]
plt.colorbar() fout = osp.join(path, '{0}.png'.format(desc)) plt.savefig(fout) plt.clf() if __name__ == '__main__': plt.ioff() # Load the cube data_path = os.environ['PYSPTOOLS_DATA'] home = os.environ['HOME'] sample = 'Smokestack1.hdr' data_file = osp.join(data_path, sample) data, header = util.load_ENVI_file(data_file) result_path = osp.join(home, 'results') if osp.exists(result_path) == False: os.makedirs(result_path) axes = parse_ENVI_header(header) # Telops cubes are flipped left-right # Flipping them again restore the orientation data = np.fliplr(data) U_full_cube, mask = get_full_cube_em_set(data, axes, result_path) U_masked = get_masked_em_set(data, axes, result_path, mask) classification_analysis(data, result_path, U_masked)
img[i, j] = data[i, j, R], data[i, j, G], data[i, j, B] d_R = np.max(img[:, :, 0]) - np.min(img[:, :, 0]) min_R = np.min(img[:, :, 0]) d_G = np.max(img[:, :, 1]) - np.min(img[:, :, 1]) min_G = np.min(img[:, :, 1]) d_B = np.max(img[:, :, 2]) - np.min(img[:, :, 2]) min_B = np.min(img[:, :, 2]) img1 = np.zeros((data.shape[0], data.shape[1], 3), dtype=np.int8) for i in range(data.shape[0]): for j in range(data.shape[1]): img1[i, j] = (1 - ((img[i, j, 0] - min_R) / d_R)) * 255, (1 - ( (img[i, j, 1] - min_G) / d_G)) * 255, (1 - ( (img[i, j, 2] - min_B) / d_B)) * 255 return img1 if __name__ == '__main__': import pysptools.util as util data_path = '../data1' project_path = '../' result_path = os.join(project_path, 'results') sample = '92AV3C.hdr' data_file = os.join(data_path, sample) data, info = util.load_ENVI_file(data_file) plot_linear_stretch(data, result_path, 102, 85, 18, '1') plot_linear_stretch(data, result_path, 98, 86, 22, '2') plot_linear_stretch(data, result_path, 75, 34, 0, '3') plot_linear_stretch(data, result_path, 74, 46, 18, '4')
for i in range(data.shape[0]): for j in range(data.shape[1]): img[i,j] = data[i,j,R], data[i,j,G], data[i,j,B] d_R = np.max(img[:,:,0])-np.min(img[:,:,0]) min_R = np.min(img[:,:,0]) d_G = np.max(img[:,:,1])-np.min(img[:,:,1]) min_G = np.min(img[:,:,1]) d_B = np.max(img[:,:,2])-np.min(img[:,:,2]) min_B = np.min(img[:,:,2]) img1 = np.zeros((data.shape[0],data.shape[1],3), dtype=np.int8) for i in range(data.shape[0]): for j in range(data.shape[1]): img1[i,j] = (1-((img[i,j,0]-min_R)/d_R))*255, (1-((img[i,j,1]-min_G)/d_G))*255, (1-((img[i,j,2]-min_B)/d_B))*255 return img1 if __name__ == '__main__': import os.path as osp import pysptools.util as util data_path = '../data1' project_path = '../' result_path = osp.join(project_path, 'results') sample = '92AV3C.hdr' data_file = osp.join(data_path, sample) data, info = util.load_ENVI_file(data_file) plot_linear_stretch(data, result_path, 102, 85, 18, '1') plot_linear_stretch(data, result_path, 98, 86, 22, '2') plot_linear_stretch(data, result_path, 75, 34, 0, '3') plot_linear_stretch(data, result_path, 74, 46, 18, '4')