-
Notifications
You must be signed in to change notification settings - Fork 0
/
runC1D.m
130 lines (90 loc) · 3.36 KB
/
runC1D.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function [finalImage, imageSuperR] = runC1D(numberOfCycles, imageFile)
%Run Chaikin at each cycle + One time Deblurring + Denoising at the end
clc; % Clear command window. % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace;
fontsize = 16;
imageOriginal = imageFile;
SDPSF = 5;
sizePSF = round(6*SDPSF+1);
degSim = 2;
sigma = 0.001;
sigmaB = 0.001;
for i=1:numberOfCycles
formatSpec = "Cycle number %d (Chaikin + Once Deblurring)";
str = sprintf(formatSpec, i);
figure("Name", str);
set(gcf,'units','normalized','outerposition',[0 0 1 1])
subplot(2,4,1);
imshow(imageOriginal, []);
title('Original Image', 'FontSize', fontsize);
axis on;
imageFile = resolutionIncrease(imageFile);
subplot(2,4,2);
imshow(imageFile, []);
title('After new SR', 'FontSize', fontsize);
axis on;
end
imageSuperR = imageFile;
testLimitSD = 10;
%testSD(imageFile,testLimitSD)
[imageDeblurred, firstPSF, finalPSF] = imageDeconv(imageFile, sizePSF, SDPSF, degSim);
%Normalizing values of image over 255
imageDeblurred = normColorVal(imageDeblurred);
testLimitSigma = 0.03;
%testSigma(imageDeblurred,testLimitSigma)
%Displaying parameters
subplot(2,4,8)
axis off;
str = {sprintf('Cycle number: %d \n', numberOfCycles), sprintf('Deblurring - PSF size = %d \n', sizePSF), sprintf('Deblurring - PSF standard deviation = %f \n', SDPSF), sprintf('Deblurring - PSF degrees of similarity = %d \n \n', degSim), sprintf('Denoising - sigma = %f \n', sigma), sprintf('Denoising Binary - sigma = %f ', sigmaB)};
text(0.0,0.5, str);
subplot(2,4,3);
imshow(imageDeblurred, []);
title('After SR-Deblurring', 'FontSize', fontsize);
axis on;
denoisedImage = denoiseImage(imageDeblurred, sigma);
denoisedImageB = denoiseImageB(imageDeblurred, sigmaB);
%Noise removal
subplot(2,4,4);
imshow(denoisedImage, []);
title('After SR-Deblurring-Denoising', 'FontSize', fontsize);
%Binary noise removal
subplot(2,4,7);
imshow(denoisedImageB, []);
title('After SR-Deblurring-Denoising Normalized', 'FontSize', fontsize);
subplot(2,4,6);
imshow(finalPSF, []);
title('Final used PSF', 'FontSize', fontsize);
axis on;
subplot(2,4,5);
imshow(firstPSF, []);
title('Initial PSF', 'FontSize', fontsize);
axis on;
finalImage = denoisedImageB;
imageCompare(denoisedImageB, imageOriginal)
formatSpec = "Image binary background removed";
str = sprintf(formatSpec, i);
figure("Name", str);
set(gcf,'units','normalized','outerposition',[0 0 1 1])
subplot(1,3,3);
imshow(imageRemoveBg(denoisedImageB), []);
title('Removed background image denoised', 'FontSize', fontsize);
axis on;
subplot(1,3,2);
imshow(imageRemoveBg(imageDeblurred), []);
title('Removed background image deblurred', 'FontSize', fontsize);
axis on;
objectBinaryMask = imageRemoveBg(imageFile);
subplot(1,3,1);
imshow(objectBinaryMask, []);
title('Removed background image SR', 'FontSize', fontsize);
axis on;
removedBgImage = extractRegion(denoisedImageB, objectBinaryMask);
denoisedImageB = equalSizeImage(denoisedImageB, removedBgImage);
clusteredImage = clusterColors(removedBgImage,3);
imageCompare(removedBgImage, imageOriginal)
imageCompare(clusteredImage, removedBgImage)
imageCompare(clusteredImage, imageOriginal)
finalImage = removedBgImage;
end