|
|
function extractFeature(imageName,conf) |
|
|
|
|
|
try |
|
|
im = im2double(imread(fullfile(conf.imagePath, [imageName '.jpg']))); |
|
|
catch |
|
|
disp(['ERROR: cannot open image ' imageName]); |
|
|
return; |
|
|
end |
|
|
|
|
|
|
|
|
for featName = conf.featNames |
|
|
clear feat |
|
|
clear hists |
|
|
clear temp |
|
|
featName = char(featName); |
|
|
feat_fname = fullfile(conf.featPath, featName, [imageName '.mat']); |
|
|
if ~exist(feat_fname,'file') |
|
|
tic |
|
|
|
|
|
[feat boxes] = feval(conf.(featName).extractFn, conf.(featName), im) ; |
|
|
|
|
|
if conf.(featName).outside_quantization |
|
|
|
|
|
temp = getRoiHistsFeat(feat.words, conf.(featName), conf.(featName).pyrLevels, boxes, 'vocabWeights', []) ; |
|
|
|
|
|
|
|
|
for li=1:length(conf.(featName).pyrLevels) |
|
|
histName = sprintf('L%d', conf.(featName).pyrLevels(li)) ; |
|
|
feat.hists.(histName) = temp{li}; |
|
|
end |
|
|
end |
|
|
ssave(feat_fname, '-STRUCT', 'feat') ; |
|
|
fprintf('image %s feature %s time %f \n', imageName, featName, toc); |
|
|
end |
|
|
end |