Help with VDSR example code
10 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm tring to learn VDSR network through matlab example:
I followed step by step the example which use the pre-trained network, but command panel shows me error: Error in test (line 46)
"Iresidual = activations(net,Iy_bicubic,21);
Undefined function 'activations' for input
arguments of type 'struct'.
Error in test (line 46)
Iresidual = activations(net,Iy_bicubic,41);"
can someone help me tell me how to fix the problem? my code is:
clear all;
%% download pretrained VDSR network:
net = load('trainedVDSR-Epoch-100-ScaleFactors-234.mat');
%% create sample low-resolution image:
exts = {'.jpg','.png'};
% fileNames contain 21 images:
fileNames = {'sherlock.jpg','car2.jpg','fabric.png','greens.jpg','hands1.jpg','kobi.png', ...
'lighthouse.png','micromarket.jpg','office_4.jpg','onion.png','pears.png','yellowlily.jpg', ...
'indiancorn.jpg','flamingos.jpg','sevilla.jpg','llama.jpg','parkavenue.jpg', ...
'peacock.jpg','car1.jpg','strawberries.jpg','wagon.jpg'};
%using image processing toolbox:
filePath = [fullfile(matlabroot,'toolbox','images','imdata') filesep];
filePathNames = strcat(filePath,fileNames);
testImages = imageDatastore(filePathNames,'FileExtensions',exts);
% display the testing images as a montage:
montage(testImages);
%% selecting one image to use as the reference image for SR:
% Index of image to read from the test image datastore
close all;
indx = 1;
Ireference = readimage(testImages,indx);
Ireference = im2double(Ireference);
imshow(Ireference);
title('High-Resolution Reference Image');
%% creating low-resolution image by using imresize
close all;
scaleFactor = 0.25;
Ilowres = imresize(Ireference,scaleFactor,'bicubic');
imshow(Ilowres);
title('Low-Resolution Image');
%% improving image resolution using pre-trained VDSR network:
close all;
[nrows,ncols,np] = size(Ireference);
Ibicubic = imresize(Ilowres,[nrows ncols],'bicubic');
% converting low resolution image from rgb2yuv
Iycbcr = rgb2ycbcr(Ilowres);
Iy = Iycbcr(:,:,1);
Icb = Iycbcr(:,:,2);
Icr = Iycbcr(:,:,3);
% up-scaling YUV image by bicubic interpulation:
Iy_bicubic = imresize(Iy,[nrows ncols],'bicubic');
Icb_bicubic = imresize(Icb,[nrows ncols],'bicubic');
Icr_bicubic = imresize(Icr,[nrows ncols],'bicubic');
%% passing the up-scalied images through trained VDSR network:
Iresidual = activations(net,Iy_bicubic,41);
Iresidual = double(Iresidual);
imshow(Iresidual,[]);
title('Residual Image from VDSR');
回答(1 个)
Subhadeep Koley
2020-1-22
The function activations was introduced inside Neural Network Toolbox in MATLAB R2016a. You can type the command ver to check whether the Neural Network Toolbox is installed or not.
ver;
Also make sure you are using MATLAB version R2016a or later.
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!