clc clear all close all load('Train_AlexNet_Feature') load('Train_AlexNet_Label') Test_AlexNet_Feature=[]; BT50=[]; mkdir('New Folder') ds = imageDatastore('/Users/kimpitman/Documents/MATLAB/Vehicle/Test'); a=ds.Files; for i=1:length(a) [I,info] = readimage( ds , i); g=imresize(I,[227,227]); imshow(g) net=alexnet; net.Layers; layer='fc7'; F=activations(net,g,layer,'outputAs','rows'); Test_AlexNet_Feature=[Test_AlexNet_Feature;F]; SVMModel=fitcsvm(Train_AlexNet_Feature,Train_AlexNet_Label,'KernelFunction','Linear'); [label,score]=predict(SVMModel,Test_AlexNet_Feature); label=label; if label(i,:)=='1' display('This is BT-50') BT=info.Filename BT=string(BT); BT50=[BT50;BT]; imwrite(g,fName(i),'.png'); %srcFiles = dir('/Users/kimpitman/Documents/MATLAB/Vehicle/Test'); % the folder in which ur images exists %for i = 1 : length(srcFiles) %filename = strcat('/Users/kimpitman/Documents/MATLAB/Vehicle/Testcopiedimages',srcFiles(i).name); %im = imread(filename); %newfilename=strcat('/Users/kimpitman/Documents/MATLAB/Vehicle/Testcopiedimages',srcFiles(i).name); %imwrite(k,newfilename,'jpg'); %end %end %newfilename=ds.Files('/Users/kimpitman/Documents/MATLAB/Vehicle/Testcopiedimages',srcFiles(i).name); %imwrite(g,newfilename,'jpg'); %imwrite(g,ds); else display('This is not BT-50') BT=info.Filename BT=string(BT); BT50=[BT50;BT]; end end save('BT50') T=table(BT50,label); fname=sprintf('LinearTestMix159%s.xlsx',datestr(now, 'yyyymmddHHMM')); writetable(T,fname,'Sheet',1)
Try This:
% Define input folder location. folder = '/Users/kimpitman/Documents/MATLAB/Vehicle/Test'; % Create output folder name. outputFolder = fullfile(folder, '/resized'); % Make output folder if it exists. if ~isfolder(outputFolder) mkdir(outputFolder) end ds = imageDatastore(folder) % Loop over all files. for k =length(ds.Files) % Get this filename. thisFileName = ds.Files{k}; fprintf('Processing %s...\n', thisFileName); % Read in the input image. originalImage = imread(thisFileName); % Display it. imshow(originalImage); drawnow; % Find out just the base filename without the folder. [thisFolder, baseFileNameNoExt, ext] = fileparts(thisFileName); % Create output image by resizing.... fprintf(' Resizing %s...\n', baseFileNameNoExt); resizedImage = imresize(originalImage, [227, 227]); % Create the output filename which will be in the output folder. outputFileName = fullfile(outputFolder, [baseFileNameNoExt, ext]); % Write the image out to the output folder. fprintf(' Saving %s...\n', outputFileName); imwrite(resizedImage, outputFileName); end message = sprintf('Done processing %d images', length(ds.Files)) uiwait(helpdlg(message));
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.