function varargout = subpixelEstimation_new(oxy,txy,cType,speType,np,f,targetImg)
%give the u,v displacement result in subpixel accuracy
%oxy ---- original coordinate
%txy ---- target coordinate found by pixel level processing
%cType ---- definition for calculation of c in this stage
%speType ---- subpixel estimation method
%np ---- number of points for fitting or interpolation of c distribution
%f ---- source pattern
%targetImg ---- target image
% this function return the [u v] in subpixel accuracy
%此处的坐标系是与整像素搜索相反的
switch (speType)
case 1 % 二维显式6个点,第6个点左上
% [ex ey cc p]=calculateSp1(oxy,txy,cType,np,f,targetImg);
[ex ey cc]=calculateSp1(oxy,txy,cType,np,f,targetImg);
case 2 % 二维显式9个点
[ex ey cc]=calculateSp2(oxy,txy,cType,np,f,targetImg);
case 3 % 二维高斯5个点
[ex ey cc]=calculateSp3(oxy,txy,cType,np,f,targetImg);
case 4 % 二维高斯9个点,MA 简化+polyfit,错误
[ex ey cc]=calculateSp4(oxy,txy,cType,np,f,targetImg);
case 5 % 一维曲线5个点
[ex ey cc]=calculateSp5(oxy,txy,cType,np,f,targetImg);
case 6 % 一维曲线9个点
[ex ey cc]=calculateSp6(oxy,txy,cType,np,f,targetImg);
case 7 % 二维隐式9个点
% [ex ey cc p]=calculateSp7(oxy,txy,cType,np,f,targetImg);
[ex ey cc]=calculateSp7(oxy,txy,cType,np,f,targetImg);
case 8 % 二维高斯9个点,原始 NaN
[ex ey cc]=calculateSp8(oxy,txy,cType,np,f,targetImg);
case 9 % 一维曲线9个点 polyfit
[ex ey cc]=calculateSp9(oxy,txy,cType,np,f,targetImg);
case 10 % 二维高斯9个点 简化, 错误
[ex ey cc]=calculateSp10(oxy,txy,cType,np,f,targetImg);
case 11 % 二维隐式9个点 polyfit
[ex ey cc]=calculateSp11(oxy,txy,cType,np,f,targetImg);
case 12 % 二维隐式9个点 复杂
[ex ey cc]=calculateSp12(oxy,txy,cType,np,f,targetImg);
case 13 % 二维显式6个点,第6个点左下
[ex ey cc]=calculateSp13(oxy,txy,cType,np,f,targetImg);
case 14 % 二维显式6个点,第6个点右上
[ex ey cc]=calculateSp14(oxy,txy,cType,np,f,targetImg);
case 15 % 二维显式6个点,第6个点右下
[ex ey cc]=calculateSp15(oxy,txy,cType,np,f,targetImg);
otherwise
end
%%%%%%%%%%%%%% End of Method %%%%%%%%%%%%%%%%%%%
%%
u = txy(2) - oxy(2) + ey;
v = txy(1) - oxy(1) + ex;
varargout{1} = u;
varargout{2} = v;
varargout{3} = cc;
% varargout{4} = p;
%% 函数--相关系数拟合法
function varargout = calculateSp1(oxy,txy,cType,np,f,targetImg)
ws = size(f,1);
%np = 3;
hfnp = floor(np/2);%np是用于进行相关系数拟合的点数
[pointsX pointsY]=meshgrid(txy(1)-hfnp:txy(1)+hfnp, txy(2)-hfnp:txy(2)+hfnp);%pointsX1是图像行向坐标
pointsX1(1:2)=pointsX(1:2);
pointsX1(3:5)=pointsX(4:6);
pointsX1(6)=pointsX(8);
pointsY1(1:2,1)=pointsY(1:2);
pointsY1(3:5,1)=pointsY(4:6);
pointsY1(6,1)=pointsY(8);
% [cValues p]= calculateC(cType,f,pointsX1,pointsY1,targetImg);
[cValues]= calculateC(cType,f,pointsX1,pointsY1,targetImg);
cValues=cValues(:);
% c0 = cValues(1);
% c1 = cValues(2);
% c2 = cValues(4);
% c3 = cValues(5);
% c4 = cValues(6);
% c5 = cValues(8);
c0 = cValues(1);
c1 = cValues(2);
c2 = cValues(3);
c3 = cValues(4);
c4 = cValues(5);
c5 = cValues(6);
a0 = c1/2 - c3 + c5/2;
a1 = c2/2 - c3 + c4/2;
a2 = c0 - c1 - c2 + c3;
a3 = c5/2 - c1/2;
a4 = c4/2 - c2/2;
a5 = c3; %% x轴是竖向
% a0 = c2/2 - c3 + c4/2;
% a1 = c1/2 - c3 + c5/2;
% a2 = c0 - c1 - c2 + c3;
% a3 = c4/2 - c2/2;
% a4 = c5/2 - c1/2;
% a5 = c3; %% x轴是横向
aa = 4*a0*a1-a2^2;
ex=(a2*a4-2*a1*a3)/aa;
ey=(a2*a3-2*a0*a4)/aa;
% ex=e(2);
% ey=e(1);
cc = a0*ex*ex + a1*ey*ey + a2*ex*ey + a3*ex + a4*ey + a5;
varargout{1}=ex;
varargout{2}=ey;
varargout{3}=cc;
% varargout{4}=p;
%%
function varargout = calculateSp2(oxy,txy,cType,np,f,targetImg)
ws = size(f,1);
%np = 3;
hfnp = floor(np/2);%np是用于进行相关系数拟合的点数
[pointsX1 pointsY1]=meshgrid( txy(1)-hfnp:txy(1)+hfnp, txy(2)-hfnp:txy(2)+hfnp );
cValues = calculateC(cType,f,pointsX1,pointsY1,targetImg);
[pointsX pointsY]=meshgrid(-hfnp:hfnp, -hfnp:hfnp);
xa1=pointsX(:);
ya1= pointsY(:);
A=[xa1.^2 ya1.^2 xa1.*ya1 xa1 ya1 ones(size(xa1))];
C=cValues(:);
% para=inv(A'*A)*A'*C;
A1=Tr(A);
A2=Ni(A1*A);
para=A2*A1*C;
a=[2*para(1) para(3);para(3) 2*para(2)];
b=Ni(a);
c=[-para(4);-para(5)];
e=b*c;
ex=e(1);
ey=e(2);
cc = para(1)*ex*ex + para(2)*ey*ey + para(3)*ex*ey + para(4)*ex + para(5)*ey + para(6);
varargout{1}=ex;
varargout{2}=ey;
varargout{3}=cc;
%%
function varargout = calculateSp3(oxy,txy,cType,np,f,targetImg)
ws = size(f,1);
%np = 3;
hfnp = floor(np/2);%np是用于进行相关系数拟合的点数
[pointsX1 pointsY1]=meshgrid( txy(1)-hfnp:txy(1)+hfnp, txy(2)-hfnp:txy(2)+hfnp );
cValues = calculateC(cType,f,pointsX1,pointsY1,targetImg);
% [pointsX pointsY]=meshgrid(-hfnp:hfnp, -hfnp:hfnp);
% xa(1)=pointsX(2);
% xa(2:4)=pointsX(4:6);
% xa(5)=pointsX(8);
% xa1=Tr(xa);
% pointsY= pointsY(:);
% ya(1)= pointsY(2);
% ya(2:4)= pointsY(4:6);
% ya(5)= pointsY(8);
% ya1=Tr(ya);
% A=[xa1.^2 ya1.^2 xa1 ya1 ones(size(xa1))];
CValues=log(abs(cValues(:)));%???有问题
c0 = cValues(2);
c1 = cValues(4);
c2 = cValues(5);
c3 = cValues(6);
c4 = cValues(8);
a0 = c0/2 - c2 + c4/2;
a1 = c1/2 - c2 + c3/2;
a2 = c4/2 - c0/2;
a3 = c3/2 - c1/2;
a4 = c2;
sigma2 = 1/(-2*a0);
miu1 = a2*sigma2;
miu2 = a3*sigma2;
ex=miu1;
ey=miu2;
cc = exp(a0*ex*ex+a1*ey*ey+a2*ex+a3*ey+a4);
varargout{1}=ex;
varargout{2}=ey;
varargout{3}=cc;%%
function varargout = calculateSp4(oxy,txy,cType,np,f,targetImg)
ws = size(f,1);
%np = 3;
hfnp = floor(np/2);
[pointsX pointsY] = meshgrid( txy(1)-hfnp:txy(1)+hfnp, txy(2)-hfnp:txy(2)+hfnp );
cValues = calculateC(cType,f,pointsX,pointsY,targetImg);
[pointsX pointsY] = meshgrid( txy(1)-hfnp:txy(1)+hfnp, txy(2)-hfnp:txy(2)+hfnp );
cValues = calculateC(cType,f,pointsX,pointsY,targetImg);
cValues = log(cValues);
c0 = cValues(1);
c1 = cValues(2);
c2 = cValues(3);
c3 = cValues(4);
c4 = cValues(5);
c5 = cValues(6);
c6 = cValues(7);
c7 = cValues(8);
c8 = cValues(9);
a0 = 1/4*c0-1/2*c1+1/4*c2-1/2*c3+c4-1/2*c5+1/4*c6-1/2*c7+1/4*c8;
a1 = -1/4*c0+1/2*c1-1/4*c2+1/4*c6-1/2*c7+1/4*c8;
a2 = -1/4*c0+1/4*c2+1/2*c3-1/2*c5-1/4*c6+1/4*c8;
a3 = 1/2*c3-c4+1/2*c5;
a4 = 1/2*c1-c4+1/2*c7;
a5 = 1/4*c0-1/4*c2-1/4*c6+1/4*c8;
a6 = -1/2*c3+1/2*c5;
a7 = -1/2*c1+1/2*c7;
a8 = c4;
%% c = a0*X^2*Y^2 + a1*X^2*Y + a2*X*Y^2 + a3*X^2 + a4*Y^2 + ...
%% +a5*X*Y + a6*X + a7*Y + a8
%% Cx = 0
%% Cy = 0
%%% Initial value from the 1D method %%%
x = -hfnp:hfnp;
nx1 = 1 + hfnp*np;
ny1 = 1 + hfnp;
nx = [nx1:nx1+np-1];
ny = [ny1:np:ny1+(np-1)*np];
yx = cValues(nx);%%%the C on x direction
yy = cValues(ny);%%%the C on y direction
p = polyfit(x,yx,2);
ex = -0.5*p(2)/p(1);
p = polyfit(x,yy,2);
ey = -0.5*p(2)/p(1);
c(1) = 2*a0*ex*ex + 2*a2*ex + 2*a4;
c(2) = a1*ex*ex + a5*ex + a7;
ey = -c(2)/c(1); %cross search on y
c(1) = 2*a0*ey*ey + 2*a1*ey + 2*a3;
c(2) = a2*ey*ey + a5*ey + a6;
ex = -c(2)/c(1);
cc = 0;
varargout{1}=ex;
varargout{2}=ey;
varargout{3}=cc;
%%
function varargout = calculateSp5(oxy,txy,cType,np,f,targetImg)
ws = size(f,1);
%np = 3;
hfnp = floor(np/2);%np是用于进行相关系数拟合的点数
[pointsX pointsY] = meshgrid(txy(1)-hfnp:txy(1)+hfnp, txy(2)-hfnp:txy(2)+hfnp );
cValues = calculateC(cType,f,pointsX,pointsY,targetImg);
C=cValues(:);
c0 = cValues(2);
c1 = cValues(4);
c2 = cValues(5);
c3 = cVa
没有合适的资源?快使用搜索试试~ 我知道了~
基于MATLAB实现的数字图像相关方法(DIC)+使用说明文档
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共8个文件
m:4个
bmp:3个
md:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 155 浏览量
2024-05-22
22:45:27
上传
评论
收藏 2.45MB ZIP 举报
温馨提示
CSDN IT狂飙上传的代码均可运行,功能ok的情况下才上传的,直接替换数据即可使用,小白也能轻松上手 【资源说明】 基于MATLAB实现的数字图像相关方法(DIC),其中DIC_FITC_sp是主程序,StepSearch是三步搜索法,CalculateC是计算相关系数的函数,SubpixelEstimation是曲面拟合法计算亚像素位移的函数+使用说明文档 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2020b;若运行有误,根据提示GPT修改;若不会,私信博主(问题描述要详细); 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、仿真咨询 如需其他服务,可后台私信博主; 4.1 期刊或参考文献复现 4.2 Matlab程序定制 4.3 科研合作 功率谱估计: 故障诊断分析: 雷达通信:雷达LFM、MIMO、成像、定位、干扰、检测、信号分析、脉冲压缩 滤波估计:SOC估计 目标定位:WSN定位、滤波跟踪、目标定位 生物电信号:肌电信号EMG、脑电信号EEG、心电信号ECG 通信系统:DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测识别融合、LEACH协议、信号检测、水声通信 5、欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
共 8 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
IT狂飙
- 粉丝: 4778
- 资源: 2640
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)