请详细解释下matlab的代码function [XCoord2D XCoord1D YCoord2D MV2D MV1D SubOpticalFlow1D] = affinemodel(A0,T0,A1,T1,lt_x,lt_y,rb_x,rb_y,h,w)% A0,T0:global motion estimation parameters% A1,T1:the first local motion parameters,the corresponding
来源:学生作业帮助网 编辑:六六作业网 时间:2024/09/01 10:08:01
请详细解释下matlab的代码function [XCoord2D XCoord1D YCoord2D MV2D MV1D SubOpticalFlow1D] = affinemodel(A0,T0,A1,T1,lt_x,lt_y,rb_x,rb_y,h,w)% A0,T0:global motion estimation parameters% A1,T1:the first local motion parameters,the corresponding
请详细解释下matlab的代码
function [XCoord2D XCoord1D YCoord2D MV2D MV1D SubOpticalFlow1D] = affinemodel(A0,T0,A1,T1,lt_x,lt_y,rb_x,rb_y,h,w)
% A0,T0:global motion estimation parameters
% A1,T1:the first local motion parameters,the corresponding coordinate,lt_x,lt_y,rb_x,rb_y
% h,w:the height and width of the frame
XCoord2D = zeros(2,h,w);
YCoord2D = zeros(2,h,w);
t_XCoord1D = zeros(2,h*w);
FullOpticalFlow2D = zeros(4,h,w);
MV2D = zeros(2,h,w);
t_MV1D = zeros(2,h*w);
SubOpticalFlow1D = zeros(4,int32(h/4)*int32(w/4));
c_h = (h+1)/2;
c_w = (w+1)/2;
step = 16;
count = 1;
for i = 1:h
for j = 1:w
XCoord2D(1:2,i,j) = [j - c_w; i - c_h];
if (mod(i,step) == 0) && (mod(j,step) == 0)
% XCoord1D(1:2,i*w+j) = [j - c_w ;i - c_h];
t_XCoord1D(1:2,count) = [j - c_w - step/2;i - c_h - step/2]; % 块的中心坐标
end
if lt_x < j && rb_x > j && lt_y < i && rb_y > i
YCoord2D(1:2,i,j) = int32(A1*XCoord2D(1:2,i,j)+T1);
else
YCoord2D(1:2,i,j) = int32(A0*XCoord2D(1:2,i,j)+T0);
end
FullOpticalFlow2D(1:4,i,j) = int32([ XCoord2D(2,i,j) XCoord2D(1,i,j) YCoord2D(2,i,j) YCoord2D(1,i,j)]);
MV2D(1:2,i,j) = [YCoord2D(1:2,i,j) - XCoord2D(1:2,i,j)];
if (mod(i,step) == 0) && (mod(j,step) == 0)
% MV1D(1:2,i*w+j) = [YCoord2D(1:2,i,j) - XCoord2D(1:2,i,j)];
t_MV1D(1:2,count) = [YCoord2D(1:2,i,j) - XCoord2D(1:2,i,j)];
count = count + 1;
end
end
end
count1 = 1;
for i = 1:h/4
for j = 1:w/4
SubOpticalFlow1D(1:4,count1) = FullOpticalFlow2D(1:4,i*4,j*4);
count1 = count1 + 1;
end
end
r_min = -min(min(SubOpticalFlow1D(1,:)),min(SubOpticalFlow1D(3,:)))+ 1
c_min = -min(min(SubOpticalFlow1D(2,:)),min(SubOpticalFlow1D(4,:)))+ 1
SubOpticalFlow1D(1,:) = SubOpticalFlow1D(1,:) + r_min;
SubOpticalFlow1D(2,:) = SubOpticalFlow1D(2,:) + c_min;
SubOpticalFlow1D(3,:) = SubOpticalFlow1D(3,:) + r_min;
SubOpticalFlow1D(4,:) = SubOpticalFlow1D(4,:) + c_min;
SubOpticalFlow1D = SubOpticalFlow1D*2;
% 对运动矢量进行整数化
MV2D = int32(MV2D);
XCoord1D = t_XCoord1D(:,1:count-1);
MV1D = int32(t_MV1D(:,1:count-1));
请详细解释下matlab的代码function [XCoord2D XCoord1D YCoord2D MV2D MV1D SubOpticalFlow1D] = affinemodel(A0,T0,A1,T1,lt_x,lt_y,rb_x,rb_y,h,w)% A0,T0:global motion estimation parameters% A1,T1:the first local motion parameters,the corresponding
是求功率谱.
Fs bit]=wavread('50.wav'); %读取波形文件,s为数据,Fs为抽样频率,bit为位宽
figure(1) %新建一个窗口
%小波去噪
[thr,sorh,keepapp]=ddencmp('den','wv',s); %返回小波除噪和压缩后的信号
[s,cxc,lxc,perf,perfl2]=wdencmp('gbl',s,'db3',3,thr,sorh,keepapp); %通过门限阈值处理得到小波系数
%求频谱
nfft=length(s); %信号长度,即抽样点数
p=floor(length(s)/3)+1; %AR预测的阶数
[spsd,f]=pyulear(s,p,nfft,Fs,'onesided'); %求功率谱密度
pmax=max(spsd); %功率谱密度最大分量
spsd=spsd/pmax; %归一化处理
%显示
plot(f(1:200),spsd(1:200)); %对应频率点的功率谱画图
a=find(spsd==1) %寻找归一化后为1的频率点的位置
f(a) %输出最大功率谱密度对应的频率