Esempio n. 1
0
    # Here begins the algorithm
    # whitening processing. It's important
    X = whiten_projection(mixed_sources)
    (sdr_ref, sir_ref, sar,
     perm) = mmetrics.bss_eval_sources(np.asarray(sources), np.asarray(X))
    print('The mean value of the reference SDR is: ', np.mean(sdr_ref))
    reference_sdr.append(np.mean(sdr_ref))

    Se = np.copy(X)
    Se_old = np.copy(Se)
    for it in np.arange(max_it):
        # 1. denoising
        Se = Dic_proj_double(Se_old, num_coeff, sigma)
        # 2. get demixing matrix
        WW = get_demix(X, Se)
        # 3. whiten the demix matrix
        WW = whiten_projection(WW)
        # 4. get the new source
        Se = np.dot(WW, X)

        if np.linalg.norm(Se - Se_old, ord='fro') < 1e-6:
            print('Dict demix convergence reached at iteration', it)
            break

        if it % 5 == 0:
            (sdr_temporary_i, sir, sar,
             perm) = mmetrics.bss_eval_sources(np.asarray(sources), Se)
            sdr_temporary.append(np.mean(sdr_temporary_i))

    (sdr, sir, sar, perm) = mmetrics.bss_eval_sources(np.asarray(sources), Se)
Esempio n. 2
0
    ssim_estimated_source1 = []
    ssim_estimated_source2 = []
    estimated_matrix = []
    mean_ssim = []

    for it in np.arange(max_it):
        # 1. denoising
        if method == 'TV':
            Se = TV_proj(Se_old, sigma)
        if method == 'bm3d':
            Se = bm3d_proj(Se_old, sigma)
        if method == 'non-local':
            Se = Nonlocal_proj(Se_old, sigma)

        # 2. get demixing matrix
        WW = get_demix(X_i, Se)
        # 3. whiten the demix matrix
        WW, W = whiten_projection(WW)
        # 4. get the new source
        Se = np.dot(WW, X_i)

        if np.linalg.norm(Se - Se_old, ord = 'fro') < 1e-6:
            print('Dict demix convergence reached at iteration', it)
            #break
        
        if it%5 == 0:
            print(it)
            (sdr_temporary_i, sir, sar, perm) = mmetrics.bss_eval_sources(np.asarray(source_channel_list_hsv[i]), Se)

            ssim1, ssim2 = SSIM(source_channel_list_hsv[i], Se, image_size, permutation, X_normalized, B_i)
            ssim_estimated_source1.append(ssim1)