|
求助大神,下面是图像融合的部分代码,是关于生成和原图像相同尺寸的权重图,但是自己对这部分不理解,不知道为什么要这么生成,就大神帮忙解答
%% focus map generation
sumMap=zeros(hei,wid);
cntMap=zeros(hei,wid);
patch_size=16;
temp_size_y=patch_size;
temp_size_x=patch_size;
stride=2;
y_bound=hei-patch_size+1;
x_bound=wid-patch_size+1;
[h,w]=size(outMap);
for j=1:h
jj=(j-1)*stride+1;
if jj<=y_bound
temp_size_y=patch_size;
else
temp_size_y=hei-jj+1;
end
for i=1:w
ii=(i-1)*stride+1;
if ii<=x_bound
temp_size_x=patch_size;
else
temp_size_x=wid-ii+1;
end
sumMap(jj:jj+temp_size_y-1,ii:ii+temp_size_x-1)=sumMap(jj:jj+temp_size_y-1,ii:ii+temp_size_x-1)+outMap(j,i);
cntMap(jj:jj+temp_size_y-1,ii:ii+temp_size_x-1)=cntMap(jj:jj+temp_size_y-1,ii:ii+temp_size_x-1)+1;
end
end
focusMap=sumMap./cntMap; |
|