visual-search/cvpr_computedescriptors.m

49 lines
1.8 KiB
Mathematica
Raw Permalink Normal View History

%% EEE3032 - Computer Vision and Pattern Recognition (ee3.cvpr)
%%
%% cvpr_computedescriptors.m
%% Skeleton code provided as part of the coursework assessment
%% This code will iterate through every image in the MSRCv2 dataset
%% and call a function 'extractRandom' to extract a descriptor from the
%% image. Currently that function returns just a random vector so should
%% be changed as part of the coursework exercise.
%%
%% (c) John Collomosse 2010 (J.Collomosse@surrey.ac.uk)
%% Centre for Vision Speech and Signal Processing (CVSSP)
%% University of Surrey, United Kingdom
close all;
clear all;
%% Edit the following line to the folder you unzipped the MSRCv2 dataset to
DATASET_FOLDER = 'dataset';
%% Create a folder to hold the results...
OUT_FOLDER = 'descriptors';
%% and within that folder, create another folder to hold these descriptors
%% the idea is all your descriptors are in individual folders - within
%% the folder specified as 'OUT_FOLDER'.
2019-12-01 02:30:20 +00:00
% OUT_SUBFOLDER='avgRGB';
2019-12-03 03:30:25 +00:00
OUT_SUBFOLDER='globalRGBhisto';
% OUT_SUBFOLDER='spatialColour';
2019-12-01 23:27:29 +00:00
% OUT_SUBFOLDER='spatialTexture';
2019-12-03 03:30:25 +00:00
% OUT_SUBFOLDER='spatialColourTexture';
allfiles=dir (fullfile([DATASET_FOLDER,'/Images/*.bmp']));
for filenum=1:length(allfiles)
fname=allfiles(filenum).name;
fprintf('Processing file %d/%d - %s\n',filenum,length(allfiles),fname);
tic;
imgfname_full=([DATASET_FOLDER,'/Images/',fname]);
img=double(imread(imgfname_full))./255;
fout=[OUT_FOLDER,'/',OUT_SUBFOLDER,'/',fname(1:end-4),'.mat'];%replace .bmp with .mat
2019-11-07 16:36:30 +00:00
%% EXTRACT FUNCTION
2019-12-01 02:30:20 +00:00
% F=extractAvgRGB(img);
2019-12-03 03:30:25 +00:00
F=extractGlobalColHist(img, 5);
% F=extractSpatialColour(img, 4, 4);
2019-12-01 23:27:29 +00:00
% F=extractSpatialTexture(img, 4, 4, 7, 0.09);
2019-12-03 03:30:25 +00:00
% F=extractSpatialColourTexture(img, 4, 4, 7, 0.09);
save(fout,'F');
toc
end