def get_padded_feature_stack(window_size, correction_switch, degree, pad=-1): eigen_full=extract_polarimetric.eigen_raster_full(window_size, correction_switch, degree) #9 is the window size cov_arr=extract_polarimetric.extract_covariance_arr(window_size, correction_switch, degree) #padding=int(np.floor(window_size/2)) padding=window_size//2 if pad!=0 else 0 Ihh=np.pad(cov_arr[...,0,0], padding, 'constant') Ihv=np.pad(cov_arr[...,1,1], padding, 'constant') Ivv=np.pad(cov_arr[...,2,2], padding, 'constant') arr_lamb1=np.pad(eigen_full[:,:,2], padding, 'constant') arr_lamb2=np.pad(eigen_full[:,:,1], padding, 'constant') arr_lamb3=np.pad(eigen_full[:,:,0], padding, 'constant') co_pol_dif=np.pad(extract_polarimetric.co_pol_diff(cov_arr), padding, 'constant') arr_det_cov=np.pad(np.absolute(extract_polarimetric.determinant_cov_conj(cov_arr)), padding, 'constant') R_co = Rco_X = np.pad(np.real(cov_arr[...,0,2]), padding, 'constant') Ico_X = np.pad(np.absolute(np.imag(cov_arr[...,0,2])), padding, 'constant') #return np.dstack((np.real(Ihh),np.real(Ihv),np.real(Ivv),np.real(arr_lamb1), np.real(arr_lamb2), np.real(arr_lamb3), np.absolute(co_pol_dif),R_co, Ico_X, np.absolute(arr_det_cov))) return np.dstack((np.real(Ihh),np.real(Ihv),np.real(Ivv),np.real(arr_lamb1), np.real(arr_lamb2), np.real(arr_lamb3), np.absolute(co_pol_dif), np.absolute(arr_det_cov)))#,R_co, Ico_X
def plot_feature_space_test(window_size): eigen_arr = extract_polarimetric.eigen_raster_full(window_size) cov_arr = extract_polarimetric.extract_covariance_arr(window_size, False) cppr = np.absolute(extract_polarimetric.co_pol_power_ratio_1(cov_arr)) co_pol_diff = np.absolute(extract_polarimetric.co_pol_diff(cov_arr)) lambda_3 = np.absolute(eigen_arr[:, :, 0]) plot_feature_space(co_pol_diff, lambda_3)
def cloude_pottier(window_size): fig, ax = plt.subplots(nrows=3, ncols=3) arr = extract_polarimetric.eigen_raster_full(window_size) cov_arr = extract_polarimetric.extract_covariance_arr(window_size) plt.subplot(3, 3, 1) plt.imshow(arr[:, :, 2], cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('lambda_1') plt.colorbar() plt.subplot(3, 3, 2) plt.imshow(arr[:, :, 1], cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('lambda_2') plt.colorbar() plt.subplot(3, 3, 3) plt.imshow(arr[:, :, 0], cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('lambda_3') plt.colorbar() plt.subplot(3, 3, 4) plt.imshow(extract_polarimetric.entropy(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('Entropy') plt.colorbar() plt.subplot(3, 3, 5) plt.imshow(extract_polarimetric.anisotropy(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('Anisotropy') plt.colorbar() plt.subplot(3, 3, 6) plt.imshow(extract_polarimetric.pol_fraction(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('Pol_fraction') plt.colorbar() plt.subplot(3, 3, 7) plt.imshow(extract_polarimetric.pedestal_height(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('pedestal_height') plt.colorbar() plt.show()
def read_Pol_features(window_size, correction_switch, degree, rescale_switch = False, log_Transform_switch = False): #os.chdir('../') eigen_full = extract_polarimetric.eigen_raster_full(window_size, correction_switch, degree) #9 is the window size cov_arr = extract_polarimetric.extract_covariance_arr(window_size, correction_switch, degree) arr_lamb1=np.absolute(eigen_full[:,:,2]) arr_lamb2=np.absolute(eigen_full[:,:,1]) arr_lamb3=np.absolute(eigen_full[:,:,0]) co_pol_dif=np.absolute(extract_polarimetric.co_pol_diff(cov_arr)) arr_det_cov=np.absolute(extract_polarimetric.determinant_cov_conj(cov_arr)) Rco_X = np.real(cov_arr[...,0,2]) Ico_X = abs(np.imag(cov_arr[...,0,2])) I_hh = np.absolute(cov_arr[...,0,0]) I_hv = np.absolute(cov_arr[...,1,1]) I_vv = np.absolute(cov_arr[...,2,2]) if (log_Transform_switch ==True): arr_lamb1 = np.log10(arr_lamb1) arr_lamb2 = np.log10(arr_lamb2) arr_lamb3 = np.log10(arr_lamb3) co_pol_dif = np.log10(co_pol_dif) arr_det_cov = np.log10(arr_det_cov) Rco_X = np.log10(Rco_X) Ico_X = np.log10(Ico_X) I_hh = np.log10(I_hh) I_hv = np.log10(I_hv) I_vv = np.log10(I_vv) if(rescale_switch == True): arr_lamb1=rescale(arr_lamb1) arr_lamb2=rescale(arr_lamb2) arr_lamb3=rescale(arr_lamb3) co_pol_dif = rescale(co_pol_dif) arr_det_cov = rescale(arr_det_cov) Rco_X = rescale(Rco_X) Ico_X = rescale(Ico_X) I_hh = rescale(I_hh) I_hv = rescale(I_hv) I_vv = rescale(I_vv) #if(log_Transform_switch ==True): #return 10*np.log10(np.dstack((arr_lamb1, arr_lamb2, arr_lamb3, co_pol_dif, arr_det_cov, Rco_X, Ico_X, I_hh, I_hv, I_vv))) #else: return np.dstack((arr_lamb1, arr_lamb2, arr_lamb3, co_pol_dif, arr_det_cov, Rco_X, Ico_X, I_hh, I_hv, I_vv))
def plot_all_UAVSAR_features(directory_MLC, window_size, correction_switch, degree): os.chdir(directory_MLC) #ax = plt.subplots(3,3) matplotlib.rcParams.update({'font.size': 3}) cov_arr = extract_polarimetric.extract_covariance_arr( window_size, correction_switch, degree) coh_arr = extract_polarimetric.extract_coherency_arr( window_size, correction_switch, degree) #===============1============= plt.subplot(5, 4, 1) plt.imshow(10 * np.log10(np.absolute(cov_arr[..., 0, 0])), cmap='gray') plt.colorbar(label='dB') plt.ylabel('Azimuth') plt.title('$I_{HH}$') plt.subplot(5, 4, 2) plt.imshow(10 * np.log10(np.absolute(cov_arr[..., 1, 1])), cmap='gray') plt.colorbar(label='dB') #plt.ylabel('Azimuth') plt.title('$I_{HV}$') plt.subplot(5, 4, 3) plt.imshow(10 * np.log10(np.absolute(cov_arr[..., 2, 2])), cmap='gray') plt.colorbar(label='dB') #plt.ylabel('Azimuth') plt.title('$I_{VV}$') #===============1============= arr_co_pol_pow_ratio = extract_polarimetric.co_pol_power_ratio_1(cov_arr) plt.subplot(5, 4, 4) plt.imshow(np.absolute(arr_co_pol_pow_ratio), cmap='gray') plt.colorbar() #plt.ylabel('Azimuth') plt.title('$\gamma_{CO}$') #===============2============= Rco_X = np.real(cov_arr[..., 0, 2]) Ico_X = np.imag(cov_arr[..., 0, 2]) plt.subplot(5, 4, 5) plt.imshow(10 * np.log10(Rco_X), cmap='gray') plt.colorbar(label='dB') plt.title('$r_{CO}$') plt.ylabel('Azimuth') #===============6============= plt.subplot(5, 4, 6) plt.imshow(10 * np.log10(abs(Ico_X)), cmap='gray') plt.colorbar(label='dB') plt.title('$|i_{CO}|$') #===============4============= plt.subplot(5, 4, 7) slc_dir = '/home/anurag/Documents/MScProject/SAR/OilSpill/North_Sea_UAVSAR/UAV_norway/UA_norway_00709_15092_000_150610_L090_CX_02' sd_phase_diff = extract_polarimetric.sd_co_pol_phase_diff(slc_dir) plt.imshow(np.absolute(sd_phase_diff), cmap='gray') plt.colorbar() plt.title('$\phi_{CO}$') #===============5============= plt.subplot(5, 4, 8) plt.imshow(10 * np.log10(extract_polarimetric.determinant_cov(cov_arr)), cmap='gray') plt.colorbar(label='dB') plt.title('$det (C_{FP})$') #plt.ylabel('Azimuth') #===============6============= plt.subplot(5, 4, 9) plt.imshow(10 * np.log10(np.absolute(cov_arr[..., 0, 0] - cov_arr[..., 2, 2])), cmap='gray') plt.colorbar(label='dB') plt.title('PD') plt.ylabel('Azimuth') #===============7============= plt.subplot(5, 4, 10) plt.imshow(np.absolute(cov_arr[..., 1, 1]) / np.absolute( (cov_arr[..., 0, 0] + cov_arr[..., 2, 2])), cmap='gray') plt.colorbar() plt.title('$P_{X}$') #===============8============= eigen_full = extract_polarimetric.eigen_raster_full( window_size, correction_switch, degree) arr_lamb1 = eigen_full[:, :, 2] arr_lamb2 = eigen_full[:, :, 1] arr_lamb3 = eigen_full[:, :, 0] #===============8============= plt.subplot(5, 4, 11) plt.imshow(10 * np.log10(np.absolute(arr_lamb1)), cmap='gray') plt.colorbar(label='dB') plt.title('$\lambda_{1}$') #===============9============= plt.subplot(5, 4, 12) plt.imshow(10 * np.log10(np.absolute(arr_lamb2)), cmap='gray') plt.colorbar(label='dB') #plt.ylabel('Azimuth') plt.title('$\lambda_{2}$') #===============10============= plt.subplot(5, 4, 13) plt.imshow(10 * np.log10(np.absolute(arr_lamb3)), cmap='gray') plt.colorbar(label='dB') plt.title('$\lambda_{3}$') plt.ylabel('Azimuth') #===============11============= plt.subplot(5, 4, 14) arr_ent = extract_polarimetric.entropy(eigen_full) plt.imshow(10 * np.log10(np.absolute(arr_ent)), cmap='gray') plt.colorbar() plt.title('$H$') #===============12============= plt.subplot(5, 4, 15) arr_pol_frac = extract_polarimetric.pol_fraction(eigen_full) plt.imshow(arr_pol_frac, cmap='gray') plt.colorbar() plt.title('$PF$') #===============13============= plt.subplot(5, 4, 16) arr_anisotropy = extract_polarimetric.anisotropy(eigen_full) plt.imshow(arr_anisotropy, cmap='gray') plt.colorbar() #plt.xlabel('Range') #plt.ylabel('Azimuth') plt.title('$A$') #================14============== plt.subplot(5, 4, 17) co_pol_corr_arr = extract_polarimetric.co_pol_correlation(cov_arr) plt.imshow(np.absolute(co_pol_corr_arr), cmap='gray') plt.colorbar() plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('$Co-pol Correlation$') #================15============== plt.subplot(5, 4, 18) arr_conform_coeff = extract_polarimetric.conformity_coeff(cov_arr) plt.imshow(np.absolute(arr_conform_coeff), cmap='gray') plt.colorbar() plt.xlabel('Range') plt.title('Conformity Coefficient') #================16============== plt.subplot(5, 4, 19) alpha = extract_polarimetric.mean_alpha_angle(eigen_full, window_size, correction_switch, degree) plt.imshow(alpha, cmap='gray') plt.colorbar(label='degrees') plt.title('Mean alpha angle') plt.xlabel('Range') #================16============== plt.subplot(5, 4, 20) PH = extract_polarimetric.pedestal_height(eigen_full) plt.imshow(PH, cmap='gray') plt.colorbar() plt.title('PH') plt.xlabel('Range') plt.tight_layout() plt.savefig( '/home/anurag/Documents/MScProject/Meetings_ITC/Results/Features/Polarimetric_Features/Inc_corr_applied/Det_cov_conj.tiff', dpi=300, box_inches='tight', papertype='a4', orientation='portrait') plt.show()
def cloude_pottier(window_size): #fig, ax = plt.subplots(nrows=3, ncols=3) arr = extract_polarimetric.eigen_raster_full(window_size) cov_arr = extract_polarimetric.extract_covariance_arr(window_size, False) #plt.subplot(3,3,1) plt.imshow(arr[:, :, 2], cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('lambda_1') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'lambda_1' + '.tiff', dpi=300) plt.clf() #plt.subplot(3,3,2) plt.imshow(arr[:, :, 1], cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('lambda_2') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'lambda_2' + '.tiff', dpi=300) plt.clf() #plt.subplot(3,3,3) plt.imshow(arr[:, :, 0], cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('lambda_3') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'lambda_3' + '.tiff', dpi=300) plt.clf() #plt.subplot(3,3,4) plt.imshow(extract_polarimetric.entropy(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('Entropy') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'Entropy' + '.tiff', dpi=300) plt.clf() #plt.subplot(3,3,5) plt.imshow(extract_polarimetric.anisotropy(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('Anisotropy') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'Anisotropy' + '.tiff', dpi=300) plt.clf() #plt.subplot(3,3,6) plt.imshow(extract_polarimetric.pol_fraction(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('Pol_fraction') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'Pol_fraction' + '.tiff', dpi=300) plt.clf() #plt.subplot(3,3,7) plt.imshow(extract_polarimetric.pedestal_height(arr), cmap='gray') plt.xlabel('Range') plt.ylabel('Azimuth') plt.title('pedestal_height') plt.colorbar() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' + 'pedestal_height' + '.tiff', dpi=300) plt.clf()
plt.xlabel('Range') plt.ylabel('dB') plt.title('PO_TSx') plt.tight_layout() plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results//Multifrequency/Detectability.tiff', dpi=300, papertype='a4', bbox_inches='tight') plt.show() ''' #=======multi_freq_ratio=========== #IVV_UAV=10*np.log10(np.absolute(C3_UAV_TS[...,2,2])) #I_VV=np.absolute(TS_x[...,1])**2 #I_VV_TSX=10*np.log10(I_VV) #multi_freq_ratio(IVV_UAV, I_VV_TSX) #===========H-alpha decomposition============== os.chdir(UAVSAR_directory_TSX) eigen_raster_full = extract_polarimetric.eigen_raster_full( window_size=9, correction_switch=False, degree=0)[35:815, 87:724, ...] H = extract_polarimetric.entropy(eigen_raster_full) A = extract_polarimetric.anisotropy(eigen_raster_full) plt.imshow(A, cmap='jet') plt.colorbar() plt.show()