Esempio n. 1
0
def occurance_kernel(
        distance, direction, texture_method, window_size, stride_row,
        stride_col):  #for one distance and 2 directions 0 and 90 degrees
    img_arr_hist_inci_corr = incidence_angle_corr.hist_stretch(
        incidence_angle_corr.inci_correction('C3', 'C33'), 5)

    rows = img_arr_hist_inci_corr.shape[0]
    cols = img_arr_hist_inci_corr.shape[1]
    #res=np.zeros((math.floor(rows/(stride_row-1))-window_size, math.floor(cols/(stride_col-1))-window_size))
    res = np.zeros(
        (math.floor(rows / stride_row), math.floor(cols / stride_col), 1, 2))
    res_row, res_col, max_res_col, max_res_row = 0, 0, 0, 0
    for i in range(0, rows - window_size, stride_row):
        for j in range(0, cols - window_size, stride_col):
            a = img_arr_hist_inci_corr[i:i + window_size, j:j + window_size]
            #print (a.astype(int))
            res[res_row,
                res_col] = return_texture_value(direction, distance,
                                                a.astype(int), texture_method)
            #print((i,j))
            res_col += 1
        max_res_col = res_col
        res_col = 0
        res_row += 1
        max_res_row = res_row
    #print(res.shape)
    #print(max_res_col, max_res_row)
    if (max_res_row < res.shape[0]):
        res = np.delete(res, np.s_[-1 * (res.shape[0] - max_res_row):], 0)
    if (max_res_col < res.shape[1]):
        res = np.delete(res, np.s_[-1 * (res.shape[1] - max_res_col):], 1)
    return res
Esempio n. 2
0
def occurance_kernel(distance, direction, texture_method, window_size, stride_row, stride_col):
    img_arr_hist_inci_corr=incidence_angle_corr.hist_stretch(incidence_angle_corr.inci_correction('C3', 'C33'), 5)
    
    rows=img_arr_hist_inci_corr.shape[0]
    cols=img_arr_hist_inci_corr.shape[1]
    #res=np.zeros((math.floor(rows/(stride_row-1))-window_size, math.floor(cols/(stride_col-1))-window_size))
    res=np.zeros((math.floor(rows/stride_row), math.floor(cols/stride_col),1,2))
    res_row, res_col, max_res_col, max_res_row= 0,0,0,0
    for i in range(0, rows-window_size, stride_row):
        for j in range(0, cols-window_size, stride_col):
            a=img_arr_hist_inci_corr[i:i+window_size, j:j+window_size]
            #print (a.astype(int))
            res[res_row,res_col]=return_texture_value(direction, distance, a.astype(int), texture_method)
            #print((i,j))
            res_col+=1
        max_res_col=res_col
        res_col=0
        res_row+=1
        max_res_row=res_row
    print(res.shape)
    print(max_res_col, max_res_row)
    if(max_res_row<res.shape[0]):
        res=np.delete(res, np.s_[-1*(res.shape[0]-max_res_row):],0)
    if(max_res_col<res.shape[1]):
        res=np.delete(res, np.s_[-1*(res.shape[1]-max_res_col):],1)
        
    #print(res[...,0,1])
    incidence_angle_corr.display(res[...,0,0], 'Range(pixel#)', 'Azimuth (pixel #)', 'Contrast GLCM feature(method='+texture_method+'dir='+str(direction[0])+', window_size='+str(window_size)+', row_stride='+str(stride_row)+', col_stride='+str(stride_col)+')')
    incidence_angle_corr.display(res[...,0,1], 'Range(pixel#)', 'Azimuth (pixel #)', 'Contrast GLCM feature(method='+texture_method+'dir='+str(direction[1])+', window_size='+str(window_size)+', row_stride='+str(stride_row)+', col_stride='+str(stride_col)+')')
Esempio n. 3
0
def occurance_kernel(direction, method, window_size, stride_row, stride_col):
    img_arr_hist_inci_corr=incidence_angle_corr.hist_stretch(incidence_angle_corr.inci_correction('C3', 'C33'), 5)
    
    rows=img_arr_hist_inci_corr.shape[0]
    cols=img_arr_hist_inci_corr.shape[1]
    #res=np.zeros((math.floor(rows/(stride_row-1))-window_size, math.floor(cols/(stride_col-1))-window_size))
    res=np.zeros((math.floor(rows/stride_row), math.floor(cols/stride_col)))
    res_row=0
    res_col=0
    for i in range(0, rows-window_size, stride_row):
        for j in range(0, cols-window_size, stride_col):
            a=img_arr_hist_inci_corr[i:i+window_size, j:j+window_size]
            res[res_row,res_col]=calc_sum(a, method, direction)
            #print((i,j))
            res_col+=1
        res_col=0
        res_row+=1
        print(i)
    incidence_angle_corr.display(res, 'Range(pixel#)', 'Azimuth (pixel #)', 'Contrast GLCM feature(dir=0, window_size=15, row_stride=2, col_stride=2)')
def polarimetric_features(window_size, correction_switch):
    #fig, ax = plt.subplots(nrows=2, ncols=3)

    #arr=extract_polarimetric.eigen_raster_full(window_size)
    cov_arr = extract_polarimetric.extract_covariance_arr(
        window_size, correction_switch)

    #plt.subplot(2,3,1)
    plt.imshow(np.absolute(extract_polarimetric.co_pol_power_ratio_1(cov_arr)),
               cmap='gray')
    plt.xlabel('Range')
    plt.ylabel('Azimuth')
    plt.title('Ivv/Ihh (Co-pol power ratio)')
    plt.colorbar()
    plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' +
                'Ivv-Ihh_(Co-pol power ratio)' + '.tiff',
                dpi=300)
    plt.clf()

    #plt.subplot(2,3,2)
    plt.imshow(incidence_angle_corr.hist_stretch(
        np.absolute(extract_polarimetric.determinant_cov(cov_arr)), 6),
               cmap='gray')
    plt.xlabel('Range')
    plt.ylabel('Azimuth')
    plt.title('Det(Cov)')
    plt.colorbar()
    plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' +
                'Det(Cov)_stretched' + '.tiff',
                dpi=300)
    plt.clf()

    #plt.subplot(2,3,2)
    plt.imshow(np.absolute(extract_polarimetric.determinant_cov(cov_arr)),
               cmap='gray')
    plt.xlabel('Range')
    plt.ylabel('Azimuth')
    plt.title('Det(Cov)')
    plt.colorbar()
    plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' +
                'Det(Cov)' + '.tiff',
                dpi=300)
    plt.clf()

    #plt.subplot(2,3,3)
    plt.imshow(np.absolute(extract_polarimetric.co_pol_diff(cov_arr)),
               cmap='gray')
    plt.xlabel('Range')
    plt.ylabel('Azimuth')
    plt.title('Co-pol diff (Ihh-Ivv)')
    plt.colorbar()
    plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' +
                'Co-pol diff(Ihh-Ivv)' + '.tiff',
                dpi=300)
    plt.clf()

    #plt.subplot(2,3,4)
    plt.imshow(np.real(extract_polarimetric.co_pol_cross_product(cov_arr)),
               cmap='gray')
    plt.xlabel('Range')
    plt.ylabel('Azimuth')
    plt.title('Real(ShhSvv) co-pol cross_product')
    plt.colorbar()
    plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' +
                'Real(ShhSvv) co-pol cross_product' + '.tiff',
                dpi=300)
    plt.clf()

    #plt.subplot(2,3,5)
    plt.imshow(np.imag(extract_polarimetric.co_pol_cross_product(cov_arr)),
               cmap='gray')
    plt.xlabel('Range')
    plt.ylabel('Azimuth')
    plt.title('Imag(ShhSvv) Co-pol cross_product')
    plt.colorbar()
    plt.savefig('/home/anurag/Documents/MScProject/Meetings_ITC/Results/' +
                'Imag(ShhSvv) Co-pol cross_product',
                dpi=300)
    plt.clf()