-
Notifications
You must be signed in to change notification settings - Fork 2
/
denoise_threshold.m
53 lines (42 loc) · 1.1 KB
/
denoise_threshold.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
% original = imread('../Clean Test Images/lena.png');
original = imread('05f35a6a-2c42-4f6a-9bad-a5f500ebe9eb.00.jpg');
original = original(:,:,1); %Rendo immagine bianco e nero (1 Channel)
original = cast(original, 'double');
% noisy = sqrt(speckleNoise(original.^2,Looks));
noisy = original;
lognoisy = zeros(size(noisy));
for i=1:size(original,1)
for j=1:size(original,2)
if noisy(i,j) <= 0
lognoisy(i,j) = 0;
else
lognoisy(i,j) = log(noisy(i,j));
end
end
end
%wname = 'bior3.5';
wname = 'bior4.4';
level = 1;
[C,S] = wavedec2(lognoisy,level,wname);
type1 = 'heursure';
type2 = 'penalhi';
thr = wthrmngr('dw2ddenoLVL',type2,C,S,3);
sorh = 's';
[XDEN,cfsDEN,dimCFS] = wdencmp('lvd',C,S,wname,level,thr,sorh);
XDEN = exp(XDEN);
mse = sum(sum(original-XDEN).^2)/(numel(original))
PSNR = 20*log10(255^2/mse)
figure;
subplot(1,2,1);
imagesc(noisy); colormap gray; axis off;
title('Noisy Image');
subplot(1,2,2);
imagesc(XDEN); colormap gray; axis off;
title('Denoised Image');
figure;
imshow(original/255);
%
% figure;
% imshow(noisy/255);
figure;
imshow(XDEN/255);