t-sne
相关性
SVM 线性核 RBM核 多项式核.
特征预处理:白化 归一化 减均值.
PCA之后白化效果会变好.
如果效果还是不好可以换换模型.
e-svm 模板经过缩放后,选取特征.选取你需要的HOG 大小.
检测时候,图像缩放不同尺度在提取特征,然后模板在不同的尺度的特征上滑动,问题出现了,这样做原因是 怕遗漏掉目标吗?相比较,不同尺度图像上sliding window然后提取特征,精度是否会提高?(但这样会带来的计算量是非常大的.)
>> a = [1 2 3;4 5 6]
a =
1 2 3
4 5 6
>> a(2)
4
for i = 1:length(models)
t = zeros(S(1),S(2),fsize);
t(1:models{i}.model.hg_size(1),1:models{i}.model.hg_size(2),:) = ...
models{i}.model.w;
templates(:,:,:,i) = t;
template_masks(:,:,:,i) = repmat(double(sum(t.^2,3)>0),[1 1 fsize]);
if (~isempty(params.nnmode)) || ...
(isfield(params,'wtype') && ...
strcmp(params.wtype,'dfun')==1)
x = zeros(S(1),S(2),fsize);
x(1:models{i}.model.hg_size(1),1:models{i}.model.hg_size(2),:) = ...
reshape(models{i}.model.x(:,1),models{i}.model.hg_size);
templates_x(:,:,:,i) = x;
end
end
%maskmat = repmat(template_masks,[1 1 1 fsize]);
%maskmat = permute(maskmat,[1 2 4 3]);
%templates_x = templates_x .* maskmat;
sbin = models{1}.model.init_params.sbin;
t = get_pyramid(I, sbin, params);
resstruct.padder = t.padder;
pyr_N = cellfun(@(x)prod([size(x,1) size(x,2)]-S+1),t.hog);
sumN = sum(pyr_N);
X = zeros(S(1)*S(2)*fsize,sumN);
offsets = cell(length(t.hog), 1);
uus = cell(length(t.hog),1);
vvs = cell(length(t.hog),1);
counter = 1;
for i = 1:length(t.hog)
s = size(t.hog{i});
NW = s(1)*s(2);
ppp = reshape(1:NW,s(1),s(2));
curf = reshape(t.hog{i},[],fsize);
b = im2col(ppp,[S(1) S(2)]);%准备在特征上滑动窗口,每个窗口内像素索引值作为b的一列
offsets{i} = b(1,:);%在特征上滑动窗口,记录每个窗口左上角索引值
offsets{i}(end+1,:) = i;
for j = 1:size(b,2)
X(:,counter) = reshape (curf(b(:,j),:),[],1);%在特征上滑动窗口
counter = counter + 1;
end
[uus{i},vvs{i}] = ind2sub(s,offsets{i}(1,:));%每个窗口左上角索引值转变成x,y坐标
end
offsets = cat(2,offsets{:});%合并所有窗口左上角的索引值
uus = cat(2,uus{:});
vvs = cat(2,vvs{:});
% m.model.w = zeros(S(1),S(2),fsize);
% m.model.b = 0;
% temp_params = params;
% temp_params.detect_save_features = 1;
% temp_params.detect_exemplar_nms_os_threshold = 1.0;
% temp_params.max_models_before_block_method = 1;
% temp_params.detect_max_windows_per_exemplar = 28000;
% [rs] = esvm_detect(I, {m}, temp_params);
% X2=cat(2,rs.xs{1}{:});
% bbs2 = rs.bbs{1};
exemplar_matrix = reshape(templates,[],size(templates,4));
if isfield(params,'wtype') && ...
strcmp(params.wtype,'dfun')==1
W = exemplar_matrix;
U = reshape(templates_x,[],length(models));
r2 = repmat(sum(W.*(U.^2),1)',1,size(X,2));
r = (W'*(X.^2) - 2*(W.*U)'*X + r2);
r = bsxfun(@minus, r, bs);
elseif isempty(params.nnmode)%得分减bs,取最小误差的窗口
%nnmode 0: Apply linear classifiers by performing one large matrix
%multiplication and subtract bias
r = exemplar_matrix' * X;
r = bsxfun(@minus, r, bs);
elseif strcmp(params.nnmode,'normalizedhog') == 1
r = exemplar_matrix' * X;
elseif strcmp(params.nnmode,'nndfun') == 1
%Do euclidean distance (but only over the regions corresponding
%to the in-mask (non-padded) regions
W = reshape(template_masks,[],length(models));
W = W / 100;
U = reshape(templates_x,[],length(models));
r2 = repmat(sum(W.*(U.^2),1)',1,size(X,2));
r = - (W'*(X.^2) - 2*(W.*U)'*X + r2);
else
error('invalid nnmode=%s\n',params.nnmode);
end
resstruct.bbs = cell(N,1);
resstruct.xs = cell(N,1);
for exid = 1:N
goods = find(r(exid,:) >= params.detect_keep_threshold);
if isempty(goods)
continue
end
[sorted_scores,bb] = ...
psort(-r(exid,goods)',...
min(params.detect_max_windows_per_exemplar, ...%取前K个误差最小的窗体
length(goods)));
bb = goods(bb);
sorted_scores = -sorted_scores';
resstruct.xs{exid} = X(:,bb);
levels = offsets(2,bb);
scales = t.scales(levels);
curuus = uus(bb);
curvvs = vvs(bb);
o = [curuus' curvvs'] - t.padder;
bbs = ([o(:,2) o(:,1) o(:,2)+size(ws{exid},2) ...
o(:,1)+size(ws{exid},1)] - 1) .* ...
repmat(sbin./scales',1,4) + 1 + repmat([0 0 -1 ...
-1],length(scales),1);%% 有待了解.
bbs(:,5:12) = 0;
bbs(:,5) = (1:size(bbs,1));
bbs(:,6) = exid;
bbs(:,8) = scales;
bbs(:,9) = uus(bb);
bbs(:,10) = vvs(bb);
bbs(:,12) = sorted_scores;
if (params.detect_add_flip == 1)
bbs = flip_box(bbs,t.size);
bbs(:,7) = 1;
end
resstruct.bbs{exid} = bbs;
end
if params.detect_save_features == 0
resstruct.xs = cell(N,1);
end
%fprintf(1,'\n');

被折叠的 条评论
为什么被折叠?



