• 大小: 34.96MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2024-01-29
  • 语言: Matlab
  • 标签: PMP  FTP  FPP  光栅  校准  

资源简介

文章“Quick pre-correction of a grating fringe for phase measuring profilometry”全套代码+实验数据。这是一种针对FPP三维测量系统的光栅预矫正方法,能够提高光栅均匀性,理论上不引入额外切向误差,整个过程可以在数秒钟以内完成。 资源包含文章全文+文章发表时的全套数据+光栅矫正代码+结果分析代码。欢迎大家参考引用。

资源截图

代码片段和文件信息

clc
clear
close all
%% 预处理
I=imread(‘0.bmp‘);

I=rgb2gray(I);
I0=I;
% [m0n0]=size(I0);

f0=0.17;
% h1=figure;
% imshow(I[]);
% title(‘左上到右下选取ROI‘);
% [pxpy]=ginput(2);
% px=round(px);
% py=round(py);

px=[109;903];
py=[181;741];

I=I(py(1):py(2)px(1):px(2));
I=double(I);
figureimshow(I[]);
title(‘未校准图像‘);
[mn]=size(I);

%% 提取峰值点
% digits(64);
fengzhi=zeros(size(I));
fengzhishow=zeros(size(I));
for aaa=1:size(I1)
    [~locs]=findpeaks(I(aaa3:end-3)‘minpeakheight‘80‘minpeakdistance‘5);
    locs=locs+2;
    fengzhishow(aaalocs)=1;%记录峰值点像素位置
    locs0=locs;
    for ii=1:length(locs)
        XX=locs(ii)-2:locs(ii)+2;
        XX0 = XX(1)-1;
        XX = XX-XX0;
        XX=XX‘;
        
        X=[XX.^2XXones(51)];
        Y=I(aaalocs(ii)-2:locs(ii)+2);
        Y=Y‘;
        C=(X‘*X)\X‘*Y;
        C(2) = C(2)-2*C(1)*XX0;
        locs(ii)=-C(2)/(2*C(1));%以邻域最小二乘估计的顶点位置作为精确坐标
        %修补空缺
        if aaa==1
            continue
        end
        xt00 = fengzhi(aaa-1locs0(ii)-1:locs0(ii)+1);
        if sum(xt00)==0
            XX=locs0(ii)-2:locs0(ii)+2;
            XX0 = XX(1)-1;
            XX = XX-XX0;
            XX=XX‘;
            X=[XX.^2XXones(51)];
            Y=I(aaa-1locs0(ii)-2:locs0(ii)+2);
            Y=Y‘;
            Cplus=(X‘*X)\X‘*Y;
            Cplus(2) = Cplus(2)-2*Cplus(1)*XX0;
            locsplus = -Cplus(2)/(2*Cplus(1));
            fengzhi(aaa-1round(locsplus))=locsplus;
            fengzhishow(aaa-1round(locsplus))=1;
        end
    end
    fengzhi(aaalocs0)=locs;%将峰值点的精确x坐标写入峰值位置
end

figureimshow(fengzhishow[]);%fengzhishow==fengzhi>0;
%% 规定坐标原点
%提取图像中角点坐标
Image=imread(‘原点.bmp‘);
Image=double(rgb2gray(Image));
Image=Image(py(1):py(2)px(1):px(2));
C=corner(Image2);%取图中最明显的两个角点
h2=figure;
imshow(Image[]);
hold on
plot(C(:1) C(:2) ‘rx‘);
hold off
C=mean(C);
% 删除原点左侧的光栅峰值
fengzhi(:1:floor(C(1)))=0;
fengzhishow(:1:floor(C(1)))=0;
%% 计算梯形校正参数
L=bwlabel(fengzhishow8);%检测8邻域连通域
num=max(L(:));
for a=1:num
    l=L==a;
    %删除长度不足的连通域
    if sum(l(:))        fengzhishow(l)=0;
        fengzhi(l)=0;
        L(l)=0;
    end
end
figureimshow(fengzhishow[]);% 不允许有光栅未提取成功
title(‘筛选后的峰值图像‘);
[~col]=find(L(1:)>0);
W=(length(col)-1)./f0;
l1=L(1min(col));
l2=L(1max(col));
[row1col1]=find(L==l1);%光栅最靠左的一列极值点
[row2col2]=find(L==l2);%光栅最靠右的一列极值点
l1=zeros(1m);
l2=zeros(1m);
for i=1:m
    l1(1i)=fengzhi(row1(i)col1(i));
    l2(1i)=fengzhi(row2(i)col2(i));
end
A=[row1ones(m1)];
b=l1‘;
p1=(A‘*A)^-1*A‘*b;
A=[row2ones(m1)];
b=l2‘;
p2=(A‘*A)^-1*A‘*b;

tana1=p1(1);
tana2=p2(1);
a1=atan(tana1);%左直线倾斜角
a2=atan(tana2);
jiaodu=(a1+a2)./2;
tanaa=tan((a1-a2)./2);

%% 生成反向补偿光栅投影
m= 574;
n= 574;
x=1:n;
y=1:m;
y=m-y+1;
[xy]=meshgrid(xy);

S = 1.12;

xt=x;
xt=-y*tanaa+xt.*(W+2*y*tanaa)./W;
xt=xt*cos(jiaodu)-y*sin(jiaodu);
% I0=0.5+0.5*cos(2*pi*f0*xt);
xy=5;
jg=2*pi/x

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-04 16:05  条纹校准\
     文件     2359350  2017-05-26 10:10  条纹校准\0.bmp
     文件     2359350  2017-05-26 10:19  条纹校准\1.bmp
     文件     2156186  2018-04-04 15:53  条纹校准\C01.mat
     文件        3345  2018-04-04 15:53  条纹校准\Correction.m
     文件        2083  2018-04-04 15:58  条纹校准\jieguofenxi_PMP1.m
     文件        2091  2018-04-04 15:58  条纹校准\jieguofenxi_PMP2.m
     文件       17396  2016-04-06 14:55  条纹校准\Miguel_2D_unwrapper.cpp
     文件       11264  2016-04-15 18:33  条纹校准\Miguel_2D_unwrapper.mexw64
     文件         427  2018-04-04 15:52  条纹校准\Original.m
     目录           0  2018-04-04 15:53  条纹校准\PMPafter1\
     文件     2359350  2017-05-26 10:22  条纹校准\PMPafter1\01.bmp
     文件     2359350  2017-05-26 10:22  条纹校准\PMPafter1\02.bmp
     文件     2359350  2017-05-26 10:22  条纹校准\PMPafter1\03.bmp
     文件     2359350  2017-05-26 10:23  条纹校准\PMPafter1\04.bmp
     文件     2359350  2017-05-26 10:23  条纹校准\PMPafter1\05.bmp
     文件     2359350  2017-05-26 10:26  条纹校准\PMPafter1\06.bmp
     文件     2359350  2017-05-26 10:26  条纹校准\PMPafter1\07.bmp
     文件     2359350  2017-05-26 10:26  条纹校准\PMPafter1\08.bmp
     文件     2359350  2017-05-26 10:27  条纹校准\PMPafter1\09.bmp
     文件     2359350  2017-05-26 10:27  条纹校准\PMPafter1\10.bmp
     目录           0  2018-04-04 15:53  条纹校准\PMPafter2\
     文件     2359350  2017-05-26 10:22  条纹校准\PMPafter2\01.bmp
     文件     2359350  2017-05-26 10:22  条纹校准\PMPafter2\02.bmp
     文件     2359350  2017-05-26 10:22  条纹校准\PMPafter2\03.bmp
     文件     2359350  2017-05-26 10:23  条纹校准\PMPafter2\04.bmp
     文件     2359350  2017-05-26 10:23  条纹校准\PMPafter2\05.bmp
     文件     2359350  2017-05-26 10:28  条纹校准\PMPafter2\11.bmp
     文件     2359350  2017-05-26 10:29  条纹校准\PMPafter2\12.bmp
     文件     2359350  2017-05-26 10:29  条纹校准\PMPafter2\13.bmp
     文件     2359350  2017-05-26 10:29  条纹校准\PMPafter2\14.bmp
............此处省略26个文件信息

评论

共有 条评论