-
Notifications
You must be signed in to change notification settings - Fork 6
/
run_LED.m
68 lines (56 loc) · 2.13 KB
/
run_LED.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
% Code by Yan Niu for TIP paper "Low Cost Edge Sensing for High Quality Demosaicking"
function [] = run_LED(testImgsPath)
% run this function test our algorithm on your RGB images
% input: the path to your test images.e.g. '.\data\MRKodak\'
close all
clc
addpath('.\utility');
addpath('.\utility\scielab1-1-1');
global imgHeight
global imgWidth
global kLogistic
kLogistic = 0.05;
global originalImg
global bayerImg
global redIndex
global blueIndex
global greenOddIndex
global greenEvenIndex
exclude = 4;
imgFiles = dir(testImgsPath);
imgFiles = imgFiles(~[imgFiles.isdir]);
numImages = numel(imgFiles);
resultNew = NaN(numImages,7);
%dataSetName = 'Kodak';
%xlswrite(strcat(dataSetName,'_result_new.xlsx'),resultNew);
for dataID = 1:numImages
disp(['processing image ' num2str(dataID) ':'])
%read an image and get its size
imgFileName = [testImgsPath imgFiles(dataID).name];
try
originalImg = double(imread(imgFileName));
catch
warning(['file', num2str(dataID), 'cannot be read properly']);
break;
end
originalImg = originalImg(1:floor(end/2)*2,1:floor(end/2)*2,:);
[imgHeight,imgWidth] = size(originalImg(:,:,1));
%GR
%BG
[bayerImg,redIndex,blueIndex,greenOddIndex,greenEvenIndex] = f_bayer_image_generation(originalImg);
[demosaicImg] = f_estimate_by_New();
%use for timing
f = @() f_estimate_by_New();
resultNew(dataID,7) = timeit(f);
%evaluation
[PSNRARR,SSIM,SCIELAB] = f_compare_imgs(demosaicImg, originalImg,exclude);
resultNew(dataID,1:4) = PSNRARR(:)';
resultNew(dataID,5) = SSIM;
resultNew(dataID,6) = SCIELAB;
end
fprintf( sprintf( '::::: average CPSNR ::::::::%f\n', mean(resultNew(:,4))) );
fprintf( sprintf( '::::: average SSIM ::::::::%f\n', mean(resultNew(:,5))) );
fprintf( sprintf( '::::: average SCIELAB ::::::::%f\n', mean(resultNew(:,6))) );
fprintf( sprintf( '::::: median TIME ::::::::%f\n', median(resultNew(2:end,7))) );
%resultNew=arrayfun(@(x) sprintf('%10.5f',x),resultNew,'un',0);
%xlswrite(strcat(dataSetName,'_result_new.xlsx'),resultNew);