这里将给出计算1(a),1(b),2(b),2(c),3(a)的Matlab代码,自己撰写并测试无误
function F = tezhen1a(ii)
minw = 2; %最小宽
minh = 1; %最小高
aw=1; %伸缩倍率,w方向
ah=1; %伸缩倍率,h方向
w=minw;
h=minh;
[row,col]=size(ii);
F=[];
while(minh*ah<=row)
while(minw*aw<=col)
for i=1:row-h
for j=1:col-w
white = ii(i,j)+ii(i+h,j+w/2)-ii(i,j+w/2)-ii(i+h,j);
black = ii(i,j+w/2)+ii(i+h,j+w)-ii(i,j+w)-ii(i+h,j+w/2);
F1((i-1)*(col-w)+j).size=[w,h];
F1((i-1)*(col-w)+j).startpoint=[i,j];
F1((i-1)*(col-w)+j).value=white-black;
end
end
F=[F,F1];
F1=[];
aw=aw+1;
w=minw*aw;
end
ah=ah+1;
h=minh*ah;
w=minw; %复位
aw=1; %复位
end
function F = tezhen1b(ii)
minw = 1; %最小宽
minh = 2; %最小高
aw=1; %伸缩倍率,w方向
ah=1; %伸缩倍率,h方向