gaussian_sigma = float(sys.argv[4]) if argc > 4 else 1.5 result_image_path = (sys.argv[5]) if argc > 5 else 'image/fig2_result.png' mode = (sys.argv[6]) if argc > 6 else 'constant' noise_rate = float(sys.argv[7]) if argc > 7 else 100 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 max_step = int(sys.argv[2]) if argc > 2 else 10 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,
result_image_path = (sys.argv[4]) if argc > 4 else 'image/fig1_result.png' raw_isnoise = int(sys.argv[5]) if argc > 5 else 0 kernel_size = 1 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: