u_hat = mysubroutines.add_NoiseAndBluf(f, kernel, lambda_weight, mode=mode, noise_rate=noise_rate) h = plt.figure() ax = h.add_subplot(111) u1 = u_hat.copy() if f.shape[2] == 1: u1 = u_hat[:, :, 0] ax.imshow(u1, cmap=plt.cm.gray) h.savefig('image/fig2_noise.png') u = mysubroutines.mysolver(u_hat, kernel, lambda_weight, mode=mode, max_step=max_step) h = plt.figure() ax = h.add_subplot(111) u1 = u.copy() if f.shape[2] == 1: u1 = u[:, :, 0] ax.imshow(u1, cmap=plt.cm.gray) #ax.imshow(u) h.savefig('image/fig2_result_lambda' + str(lambda_weight) + '_ite' + str(max_step) + '.png')
gaussian_sigma = 1.5 noise_rate = 0.1 kernel = mysubroutines.fspecial(kernel_size, gaussian_sigma) f = mpimg.imread(image_path) if len(f.shape) < 3: f = np.reshape(f, [*f.shape, 1]) if np.max(f) > 1.0: f = f / 255 if raw_isnoise == 0: u_hat = mysubroutines.add_NoiseAndBluf(f, kernel, noise_rate=noise_rate) else: u_hat = f u1 = u_hat.copy() if f.shape[2] == 1: u1 = u_hat[:, :, 0] misc.imsave('image/fig1_noise.png', u1) plt.close('all') h1 = plt.figure() ax1 = h1.add_subplot(121) ax1.imshow(u1, cmap=plt.cm.gray) u = mysubroutines.mysolver(u_hat, C=C, K=K, mode_L=mode_L, T=T) u2 = u.copy() if f.shape[2] == 1: u2 = u2[:, :, 0] misc.imsave(result_image_path, u2)