|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| format compact;
|
| global sigmas;
|
| addpath(fullfile('utilities'));
|
|
|
| folderModel = 'models';
|
| folderTest = 'testsets';
|
| folderResult= 'results';
|
| imageSets = {'RNI6'};
|
| setTestCur = imageSets{1};
|
|
|
| showResult = 1;
|
| useGPU = 1;
|
| pauseTime = 0;
|
|
|
|
|
| inputNoiseSigma = 15;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| folderResultCur = fullfile(folderResult, [setTestCur,'_',num2str(inputNoiseSigma)]);
|
| if ~isdir(folderResultCur)
|
| mkdir(folderResultCur)
|
| end
|
|
|
| load(fullfile('models','FFDNet_gray.mat'));
|
| net = vl_simplenn_tidy(net);
|
|
|
|
|
|
|
|
|
|
|
| if useGPU
|
| net = vl_simplenn_move(net, 'gpu') ;
|
| end
|
|
|
|
|
| ext = {'*.jpg','*.png','*.bmp'};
|
| filePaths = [];
|
| for i = 1 : length(ext)
|
| filePaths = cat(1,filePaths, dir(fullfile(folderTest,setTestCur,ext{i})));
|
| end
|
|
|
|
|
| for i = 1
|
|
|
|
|
| disp([filePaths(i).name])
|
| label = imread(fullfile(folderTest,setTestCur,filePaths(i).name));
|
| [w,h,~]=size(label);
|
| if size(label,3)==3
|
| label = rgb2gray(label);
|
| end
|
|
|
| [~,nameCur,extCur] = fileparts(filePaths(i).name);
|
| input = im2single(label);
|
|
|
| if mod(w,2)==1
|
| input = cat(1,input, input(end,:)) ;
|
| end
|
| if mod(h,2)==1
|
| input = cat(2,input, input(:,end)) ;
|
| end
|
|
|
|
|
| if useGPU
|
| input = gpuArray(input);
|
| end
|
|
|
|
|
| sigmas = inputNoiseSigma/255;
|
|
|
|
|
| res = vl_simplenn(net,input,[],[],'conserveMemory',true,'mode','test');
|
|
|
|
|
|
|
|
|
| output = res(end).x;
|
|
|
| if mod(w,2)==1
|
| output = output(1:end-1,:);
|
| input = input(1:end-1,:);
|
| end
|
| if mod(h,2)==1
|
| output = output(:,1:end-1);
|
| input = input(:,1:end-1);
|
| end
|
|
|
|
|
| if useGPU
|
| output = gather(output);
|
| input = gather(input);
|
| end
|
|
|
| if showResult
|
| imshow(cat(2,im2uint8(input),im2uint8(output)));
|
| title([filePaths(i).name])
|
| imwrite(im2uint8(output), fullfile(folderResultCur, [nameCur, '_' num2str(inputNoiseSigma,'%02d'), '.png'] ));
|
| drawnow;
|
| pause(pauseTime)
|
| end
|
|
|
|
|
| end
|
|
|
|
|
|
|
|
|
|
|