加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vector_decomposition.m 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
Hui Li(李辉) 提交于 2019-12-21 11:54 . fusion method files
function [I_b, I_d, I_d_v, count_matric, I_vector] = vector_decomposition(img, L, unit, is_overlap, stride, w_num)
% lrr parts and salient parts
% stride = 4;
% image, using reflecting to resize input image
[t1,t2] = size(img);
h = t1;
w = t2;
s = stride;
% figure;imshow(img_or);
% figure;imshow(img);
% salient parts by latlrr
I_d = zeros(h, w);
% the matrices for overlapping
count_matric = zeros(h, w);
ones_matric = ones(unit,unit);
if is_overlap == 1
c1 = 0;
for i=1:s:h-unit+1
c2 = 0;
c1 = c1+1;
for j=1:s:w-unit+1
c2 = c2+1;
temp = img(i:(i+unit-1), j:(j+unit-1));
temp_vector(:,(c1-1)*(w_num)+c2) = temp(:);
% record the overlapping number
count_matric(i:(i+unit-1), j:(j+unit-1)) =...
count_matric(i:(i+unit-1), j:(j+unit-1)) + ones_matric(:, :);
end
end
img_vector = temp_vector;
% calculate features
I_d_v = L*temp_vector;
c1 = 0;
for ii=1:s:h-unit+1
c2 = 0;
c1 = c1+1;
for jj=1:s:w-unit+1
c2 = c2+1;
temp = I_d_v(:, (c1-1)*(w_num)+c2);
I_d(ii:(ii+unit-1), jj:(jj+unit-1)) = I_d(ii:(ii+unit-1), jj:(jj+unit-1)) + reshape(temp, [unit unit]);
end
end
% average operation for overlapping position
I_d = I_d./count_matric;
% I_d = I_d(1:t1, 1:t2);
else
% stride = unit
I_col = im2col(img, [unit, unit], 'distinct');
salient = L*I_col;
I_d_v = salient;
I_d = col2im(salient,[unit, unit],[t1,t2],'distinct');
I_d(I_d<0) = 0;
end
% base parts
I_b = img - I_d;
I_vector = img_vector;
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化