-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo2D.m
72 lines (56 loc) · 1.56 KB
/
demo2D.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
%% 2D Image denoising using undecimated wavelet transform
%
% Ankit Parekh (ankit.parekh@nyu.edu), NYU School of Engineering
% Reference:
% Convex denoising using non-convex tight frame regularization
% Ankit Parekh and Ivan W. Selesnick
% IEEE Signal Process. Lett., 2015
%% Initializations
clear; clc; close all
rmse = @(y,x) sqrt( sum( (y(:)-x(:)).^2) / numel(y) );
psnr = @(x,y) 10*log10 ( 1 / rmse(im2double(x),im2double(y))^2);
addpath Functions
addpath Functions/WaveletFunctions
%% Load Image and generate Noisy version of the image
S = rgb2gray(imread('peppers.png'));
S = double(S);
rng('default')
sigma = 50;
Y = S + sigma*randn(size(S));
J = 5;
[AH, A, normA] = MakeTransforms('2D-CDWT',size(Y),J);
figure(1), clf
subplot(1,2,1)
imshow(uint8(S));
title('Original Image')
subplot(1,2,2)
imshow(uint8(Y));
title(sprintf('Noisy Image, PSNR = %2.2f dB',psnr(uint8(S),uint8(Y))))
%% Denoise the image
Lam_l1 = 0.9*sigma;
Lam_ncvx = 1.1*sigma;
a = 1/(Lam_ncvx);
mu = 2;
Nit = 15;
nit = 1:Nit;
x = bp_ncvx2DCWT(Y,A,AH,J,Lam_ncvx,a,mu,Nit,'atan');
xL1 = bp_ncvx2DCWT(Y,A,AH,J,Lam_l1,1,mu,Nit,'l1');
%% Plot the denoised images
figure(2), clf
subplot(2,2,1)
imshow(uint8(S))
title('Original Image')
box off
subplot(2,2,2)
imshow(uint8(Y))
title(sprintf('Noisy Image \nPSNR = %2.1f dB',psnr(uint8(S),uint8(Y))))
box off
subplot(2,2,3)
imshow(uint8(xL1))
title(sprintf('L1 \nPSNR = %2.1f dB',psnr(uint8(S),uint8(xL1))))
box off
subplot(2,2,4)
imshow(uint8(x))
title(sprintf('Non-convex \nPSNR = %2.1f dB',psnr(uint8(S),uint8(x))),...
'horizontalAlignment','center')
box off