?? bag_of_words.m
字號(hào):
function wf = bag_of_words(fv,pos,C,Y,X,par)
V = size(C,2);
nPunts = size(fv,2);
%%% Set distance matrix to all be large values
distance = Inf * ones(nPunts,size(C,2));
%%% Loop over all centers and all points and get L2 norm btw. the two.
for p = 1:nPunts
for c = 1:size(C,2)
distance(p,c) = norm(C(:,c) - double(fv(:,p)));
end
end
%%% Now find the closest center for each point
[tmp,words] = min(distance,[],2);
words = words';
wf = zeros(Y,X,par.nRegions);
for i=1:size(words,2)
j=1;
en=0;
while j<=par.nRegions && ~en
if wf(pos(2,i),pos(1,i),j) == 0
wf(pos(2,i),pos(1,i),j) = words(1,i);
en = 1;
else
j=j+1;
end
end
end
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -