⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bag_of_words.m

📁 phow is the code for extracting pyramid features from image
💻 M
字号:
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
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -