working mahalanobis
This commit is contained in:
parent
aaa4feae09
commit
752243d192
@ -27,10 +27,10 @@ DATASET_FOLDER = 'dataset';
|
||||
DESCRIPTOR_FOLDER = 'descriptors';
|
||||
%% and within that folder, another folder to hold the descriptors
|
||||
%% we are interested in working with
|
||||
DESCRIPTOR_SUBFOLDER='avgRGB';
|
||||
% DESCRIPTOR_SUBFOLDER='avgRGB';
|
||||
% DESCRIPTOR_SUBFOLDER='globalRGBhisto';
|
||||
% DESCRIPTOR_SUBFOLDER='spatialColour';
|
||||
% DESCRIPTOR_SUBFOLDER='spatialColourTexture';
|
||||
DESCRIPTOR_SUBFOLDER='spatialColourTexture';
|
||||
|
||||
CATEGORIES = ["Farm Animal"
|
||||
"Tree"
|
||||
@ -101,10 +101,10 @@ for iteration=1:CAT_TOTAL
|
||||
|
||||
%% 3) Compute EigenModel
|
||||
E = getEigenModel(ALLFEAT);
|
||||
E = deflateEigen(E, 2);
|
||||
E = deflateEigen(E, 12);
|
||||
|
||||
%% 4) Project data to lower dimensionality
|
||||
% ALLFEAT=ALLFEAT-repmat(E.org,size(ALLFEAT,1),1);
|
||||
ALLFEAT=ALLFEAT-repmat(E.org,size(ALLFEAT,1),1);
|
||||
ALLFEAT=((E.vct')*(ALLFEAT'))';
|
||||
|
||||
%% 3) Compute the distance of image to the query
|
||||
@ -116,7 +116,7 @@ for iteration=1:CAT_TOTAL
|
||||
category=ALLCATs(i);
|
||||
|
||||
%% COMPARE FUNCTION
|
||||
thedst=compareMahalanobis(E, ALLFEAT, query);
|
||||
thedst=compareMahalanobis(E, query, candidate);
|
||||
dst=[dst ; [thedst i category]];
|
||||
end
|
||||
dst=sortrows(dst,1); % sort the results
|
||||
@ -134,7 +134,6 @@ for iteration=1:CAT_TOTAL
|
||||
end
|
||||
fprintf('category was %s\n', CATEGORIES(query_category))
|
||||
|
||||
|
||||
%calculate PR for each n
|
||||
for i=1:NIMG
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
function dst=compareL1(F1, F2)
|
||||
|
||||
x=F1-F2;
|
||||
x=abs(F1-F2);
|
||||
dst=sum(x);
|
||||
|
||||
return;
|
||||
|
@ -1,17 +1,9 @@
|
||||
function d=compareMahalanobis(E, obs, query)
|
||||
function d=compareMahalanobis(E, query, candidate)
|
||||
|
||||
obs_translated = (obs -repmat(query, size(obs,1), 1))';
|
||||
x=query-candidate;
|
||||
x=(x.^2)./(E.val');
|
||||
x=sum(x);
|
||||
|
||||
proj=E.vct*obs_translated;
|
||||
|
||||
dstsq=proj.*proj;
|
||||
|
||||
E.val(E.val==0)=1; % check for eigenvalues of 0
|
||||
|
||||
dst=dstsq./repmat((E.val),1,size(obs,2));
|
||||
|
||||
d=sum(dst);
|
||||
|
||||
d=sqrt(d);
|
||||
d=sqrt(x);
|
||||
|
||||
return;
|
||||
|
@ -19,7 +19,7 @@ for i = 1:rows
|
||||
end
|
||||
|
||||
if size(vals, 2) == 0
|
||||
F = zeros(1, bins)
|
||||
F = zeros(1, bins);
|
||||
else
|
||||
F= histogram(vals, bins, 'Normalization', 'probability').Values;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user