-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathACS_Net_MultiScale.m
executable file
·91 lines (82 loc) · 2.92 KB
/
ACS_Net_MultiScale.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
% This is an implement of strategy 2(add Sample strategy );
clear
t1 = clock;
delete('SampleRate.txt');
%this global param controls the block image order;
saveResult = 1;
showResult = 1;
global useGPU;
useGPU = 0;
global blockNo;
blockNo = 0;
%blocksize of blockproc;
blockSize = 64;
%%
imageNo = 450;
%Choose image;
image = imread(['../BigData/datasets/reference-890/GroundTruth/','image',num2str(imageNo),'.png']);
if size(image,3)==3
image = rgb2ycbcr(image);
image = im2double(image(:, :, 1));
else
image = im2double(image);
end
% convert image -> can be mod by 32;
image =modcrop(image,32);
%%
%base Sampling by SR of 0.05;
%基础采样部分:
baseInitRec = ACS_Net_initRec(image,0.05);
%%
%compute Entropy matrix by baseInitRec!!
%根据初始重构分块计算图像熵:
%注意:使用"entropy"时,使用entropy函数来计算熵; 使用"entropyfilt"时,使用entropyfilt函数来计算熵; 两者结果可能不同;
fun = @(block_struct)ComputeEntropy(block_struct.data,"entropy");
entropyMatrix = blockproc(baseInitRec,[blockSize,blockSize],fun);
%convert the entropyMatrix to a 1D entropyVector;
entropyVector = getEntropyVector(entropyMatrix);
%sort the entropyVector;
sortedEntropyVector = sort(entropyVector);
%%
%补充采样部分:
%分块分不同采样率补充采样,获得残差;这里需要用到entropyVector和sortedEntropyVector;
fun = @(block_struct)MutiScaleResidual(block_struct.data,entropyVector,sortedEntropyVector);
initEnResidual = blockproc(image,[blockSize blockSize],fun);
%基准初始重构+补充采样的残差=恢复的初始重构
TotalinitRec = initEnResidual + baseInitRec;
%%
%deep Reconstruction!
%深度重构:
deepReconstruction = initial2Deep(TotalinitRec);
%%
%evaluate the quality of the result && show result
if showResult
[psnr_base,ssim_base] = Cal_PSNRSSIM(im2uint8(image) ,im2uint8(baseInitRec),0,0);
[psnr_totalInit,ssim_totalInit] = Cal_PSNRSSIM(im2uint8(image) ,im2uint8(TotalinitRec),0,0);
[psnr_deep,ssim_deep] = Cal_PSNRSSIM(im2uint8(image) ,im2uint8(deepReconstruction),0,0);
subplot(1,4,1);
imshow(baseInitRec);
title('0.05采样率的基准初始重构');
subplot(1,4,2);
imshow(TotalinitRec);
title('补充采样后的初始重构');
subplot(1,4,3);
imshow(deepReconstruction);
title('深度重构');
subplot(1,4,4);
imshow(image);
title('原图');
%display the average Sample Rate;
filename = 'SampleRate.txt';
SRs=textread(filename,'%f');
AvgSampleRate = mean(SRs);
fprintf('Average Sample Rate = %g\n',AvgSampleRate);
end
t2 = clock;
runtime = etime(t2,t1);
%%
%save Initial Result && Deep Result!
if saveResult == 1
imwrite(TotalinitRec, ['../BigData/datasets/reference-890/InitialResult/','image',num2str(imageNo),'.png']);
imwrite(deepReconstruction,['../BigData/datasets/reference-890/DeepResult/','image',num2str(imageNo),'.png']);
end