Ejemplo n.º 1
0
def compute_Ws(I):
    dx = np.array([0, 0, 0, -1, 0, 1, 0, 0, 0]).reshape(3, 3)
    dy = np.array([0, -1, 0, 0, 0, 0, 0, 1, 0]).reshape(3, 3)
    DxI = frame_utility.cconv2d(dx, I)
    DyI = frame_utility.cconv2d(dy, I)
    Ws = weight_matrix(np.abs(DxI) + np.abs(DyI))
    return Ws
Ejemplo n.º 2
0
def compute_Ax2(I, Ws):
    dx = np.array([0, 0, 0, -1, 0, 1, 0, 0, 0]).reshape(3, 3)
    dy = np.array([0, -1, 0, 0, 0, 0, 0, 1, 0]).reshape(3, 3)
    DxI = frame_utility.cconv2d(dx, I)
    WsDxI = Ws * DxI
    DxtWsDxI = frame_utility.cconv2dt(dx, WsDxI)
    DyI = frame_utility.cconv2d(dy, I)
    WsDyI = Ws * DyI
    DytWsDyI = frame_utility.cconv2dt(dy, WsDyI)
    AI2 = DxtWsDxI + DytWsDyI
    return AI2
Ejemplo n.º 3
0
def compute_Ax1(I, W0, th, h_2d, scale_factor):
    KI = frame_utility.cconv2d(h_2d, I)
    SKI = frame_utility.down_sample(KI, scale_factor)
    W0SKI = W0 * SKI
    StW0SKI = frame_utility.up_sample(W0SKI, scale_factor)
    KtStW0SKI = frame_utility.cconv2dt(h_2d, StW0SKI)
    AI1 = th * KtStW0SKI
    return AI1
Ejemplo n.º 4
0
def compute_Ax1_k(K, I, Wk, th, scale_factor):
    AK = frame_utility.cconv2d(K, I)
    SAK = frame_utility.down_sample(AK, scale_factor)
    WkSAK = Wk * SAK
    StWkSAK = frame_utility.up_sample(WkSAK, scale_factor)
    AtStWkSAK = frame_utility.cconv2dt(I, StWkSAK)
    AK1 = th * AtStWkSAK
    return AK1
Ejemplo n.º 5
0
def compute_Ax3(FI, Wi, th, h_2d, scale_factor, ut, vt):
    KFI = frame_utility.cconv2d(h_2d, FI)
    SKFI = frame_utility.down_sample(KFI, scale_factor)
    WSKFI = Wi * SKFI
    StWSKFI = frame_utility.up_sample(WSKFI, scale_factor)
    KtStWSKFI = frame_utility.cconv2dt(h_2d, StWSKFI)
    FtKtStWSKFI = frame_utility.warped_img(KtStWSKFI, ut, vt)
    AI3 = th * FtKtStWSKFI
    return AI3
Ejemplo n.º 6
0
                                        current_I, current_sr[j + i])
                        ut[j + i] = -u[j + i]
                        vt[j + i] = -v[j + i]
                        FI[j + i] = frame_utility.warped_img(
                            current_I, u[j + i], v[j + i])

            # estimate noise
            nq = low_res_width * low_res_height
            print('noise estimation ...')
            if k == 0:
                for i in range(-n_back, n_for + 1):
                    theta[j + i] = max(1, max(n_back, n_for)) / (abs(i) + 1)
            else:
                for i in range(-n_back, n_for + 1):
                    if i == 0:
                        KI = frame_utility.cconv2d(h_2d, current_I)
                        SKI = frame_utility.down_sample(KI, scale_factor)
                        x_tmp = np.sum(np.abs(current_low[j + i] - SKI)) / nq
                        theta[j + i] = (alpha + nq - 1) / (beta + nq * x_tmp)
                    else:
                        KFI = frame_utility.cconv2d(h_2d, FI[j + i])
                        SKFI = frame_utility.down_sample(KFI, scale_factor)
                        x_tmp = np.sum(np.abs(current_low[j + i] - SKFI)) / nq
                        theta[j + i] = (alpha + nq - 1) / (beta + nq * x_tmp)

            # estimate high resolution image
            print('high resolution image estimation .. ')
            for m in range(max_iteration):
                print('%d th high resolution estimation IRLS iteration' % m)
                I_old_in = current_I
                W0 = kernel_utility.compute_W0(current_I, J0, h_2d,
Ejemplo n.º 7
0
def compute_Wk(K, I, J0, scale_factor):
    AK = frame_utility.cconv2d(K, I)
    SAK = frame_utility.down_sample(AK, scale_factor)
    Wk = weight_matrix(SAK - J0)
    return Wk
Ejemplo n.º 8
0
def compute_Wi(FI, J, h_2d, scale_factor):
    KFI = frame_utility.cconv2d(h_2d, FI)
    SKFI = frame_utility.down_sample(KFI, scale_factor)
    Wi = weight_matrix(SKFI - J)
    return Wi
Ejemplo n.º 9
0
def compute_W0(I, J0, h_2d, scale_factor):
    KI = frame_utility.cconv2d(h_2d, I)
    SKI = frame_utility.down_sample(KI, scale_factor)
    W0 = weight_matrix(SKI - J0)
    return W0