-
改进后枝切法总体上采用Goldstein枝切法解包裹流程,重点对相位图进行预处理消除残差点,算法实现包括以下要点。
(1) 电磁力计算函数,以整张图片(或选择图片区域)为计算对象,按像素密度找到所有残差点,记录其坐标和正负标识。按公式(2)、(3)分别求出每个残差点合力(包含大小和方向)。函数定义核心逻辑如下(以C语言编程为例):
Void Electric Force()
{
…
float dist=sqrtf((forces[j].ec.x-forces[i].ec.x)*(forces[j].ec.x−forces[i].ec.x)+
(forces[j].ec.y−forces[i].ec.y)*(forces[j].ec.y-forces[i].ec.y));
f.fx=(forces[j].ec.x-forces[i].ec.x)/(dist*dist);
f.fy=(forces[j].ec.y−forces[i].ec.y)/(dist*dist);
if(forces[i].ec.pol==forces[j].ec.pol)
{
f.fx*=−1;
f.fy*=−1;
}
forces[i].fx+=f.fx;
forces[i].fy+=f.fy;
…
} //其中forces[]为残差点合力数组,ec为残差点电量数据结构,包括坐标x,y,正负标识pol,i,j为残差点的序号,f为电磁力。
(2) 残差点移动函数,遍历所有残差点,沿各自受力方向(和分界线位置关系)按像素移动,空出位置采用平滑和增加明暗跳变处理,函数定义核心逻辑如下:
bool Move Wind Point By EF(float MinF)
{
…
//若合力与分界线夹角小于60°或大于120°
…
if(fx*dirx+fy*diry>0)//合力与分界线方向相符,采用平滑处理
{
..
avrd=(local_d[j−1][i−1]+local_d[j−1][i]+local_d[j−1][i+1]+
local_d[j][i−1]+local_d[j][i]+local_d[j][i+1]+
local_d[j+1][i−1]+local_d[j+1][i]+local_d[j+1][i+1])/9;
local_d[j][i]=avrd;
..
}
else //合力与分界线方向相反,增加明暗跳变处理
{
avrd=(local_d[j−1][i−1]+local_d[j−1][i]+local_d[j−1][i+1]+
local_d[j][i−1]+local_d[j][i]+local_d[j][i+1]+
local_d[j+1][i−1]+local_d[j+1][i]+local_d[j+1][i+1]);
if (local_d[j][i]<128)
{
avrd-=256*count_skip;
}
else
{
avrd+=256*count_skip;
}
avrd/=9;
local_d[j][i]=avrd;
…
}
} //其中local_d[j][i]为待处理残差点相位值,count_skip为跳变次数。
(3)电磁力阈值(MinF),大多情况下残差点不能完全消除,为防止程序死循环,需要设置电磁力阈值,用于终止遍历过程,电磁力阈值设值大,会提早跳出循环,留下不处理的残差点过多,电磁力阈值设值小,会产生无效循环,耗费时间。实验发现设为0.0002~0.0005较为合适,同时设置最大循环次数辅助逻辑判断,效率更高。
(4) GPU并行计算要点,采用GPU并行计算时速度瓶颈大多出现在数据传输阶段,包括系统内存与GPU显存间的传输、GPU核心与显存间的传输、线程块内共享内存的读写和线程块与全局显存间的读写。数据传输量越少、显存读写连续性越好,越有利于发挥GPU计算速度快的优点。算法实现时应尽可能减少GPU与CPU的数据传递,为消除解包裹前期冗余的数据的传送过程,可将相位提取(求相位差)与滤波合并计算。此外,性能不同的GPU可以采取不同的算法在计算速度和精度之间取得平衡。对性能较低的GPU,可以适当降低精度要求,采用正余弦均值滤波通过减少滤波次数的方式提高滤波速度,保证实时性;对于性能较强的GPU,可以采用如Butterworth低通滤波等大计算量算法来同时获得较好的滤波效果和图像处理的实时性。
-
搭建迈克尔逊剪切散斑干涉测量系统(见图8),采用德国Basler scA2500-60 μm工业相机,CCD靶面尺寸1″,成像镜头采用焦距为12 mm、靶面尺寸1″的日本moritex镜头,光源采用波长为532 nm的单纵模绿光激光器,被测物为500 mm×300 mm×30 mm、表面粘贴0.5 mm铝合金蒙皮的蜂窝夹层结构标准试件,其内预置有Ф40 mm、Ф20 mm和Ф15 mm的三种脱胶点。
Figure 8. System measurement device. (a) Measurement platform and scene; (b) Michelson shearing device; (c) Measured object
将标准试件固定,利用吹风机均匀加热,随着样板表面温度的降低,样板表面出现连续形变,采用“四步相移法”[1]随机拍得标准试件形变前后各4幅500万像素(2592×2 048)的散斑图。通过四步相移求相位公式,计算求得相位图。采用正余弦滤波算法经过20次滤波后,得到清晰的相位图。以该图为输入,采用传统枝切法和文中优化后的枝切法进行解包裹。得到结果如图9所示。
Figure 9. Unwrapping by branch-cut method. (a) The four speckle diagrams before deformation; (b) The four speckle diagrams after deformation; (c) Original phase diagram; (d) The phase diagram after filtering; (e) Unwrapping diagram by traditional branch-cut method; (g) Unwrapping diagram by improved branch-cut method
从图9可以看出,两种解包裹算法从整体上都能观察到缺陷的位置和大小,但优化后枝切法解包裹算法由于提前进行了残差点消除处理,它的结果图中几乎没有拉丝和斑块现象,图像质量明显更优。
在速度方面,基于intel i7-6500U CPU@2.5 GHz 处理器、NVIDIA GeForce 940MX@1004 MHz显卡,采用单一CPU图像计算和利用GPU并行计算两种方式,对图9中原始图进行求相位、滤波、解包裹操作,表1为图像处理耗时分布。
Operate Parameters Time consuming/ms CPU GPU Phase calculation 5 million pixels 719 148 sin-cos filtering “3×3”,20 times 17571 403 Branch-cut unwrapping 89 residual points 1142 901 Table 1. Computing time of phase diagram processing
由于求相位、滤波相对解包裹处理逻辑更简单,整体是以单个像素点为对象单独计算,计算中CPU、GPU之间数据交互少,速度提升更显著。采用GPU并行计算处理时间均控制在1500 ms以内,满足了高分辨率散斑图快速计算的工程应用需要。
Application of improved branch-cut method in speckle phase unwrapping
doi: 10.3788/IRLA20200451
- Received Date: 2020-11-24
- Rev Recd Date: 2021-02-24
- Publish Date: 2021-10-20
-
Key words:
- branch-cut method /
- laser speckle interferometry /
- phase diagram wrapping /
- GPU parallel computing /
- electromagnetic force guidance
Abstract: In order to realize the engineering application of the branch-cut method in the phase diagram unwrapping of laser speckle pattern interferometry, and to solve the problems of dense branch lines and slow calculation speed caused by the interference of external light, the degradation of laser performance and the undersampling of local points taken by cameras, an optimization and improvement scheme based on Goldstein branch-cut method was proposed. The residual points were regarded as "electrons" with positive and negative unit electric quantities, guided by electromagnetic force, and eliminated by phase smoothing or increasing phase jump, thus reducing the number of branch lines. At the same time, GPU parallel computing technology was adopted to improve the processing speed of high-resolution and large-size phase diagram. The simulation experiment and actual measurement data show that the unwrapping diagram quality is better by the improved branch-cut method. For the 5 million pixel speckle phase diagram, more than 98% of the residual points can be eliminated by electromagnetic force, and the branch lines can be reduced by more than 90%. The processing time can be reduced from the previous 15 seconds to 1.5 seconds, which meets the engineering application requirements of high quality and quick unwrapping by branch-cut method.