-
大小: 280KB文件类型: .tar金币: 1下载: 0 次发布日期: 2021-05-26
- 语言: 其他
- 标签: Phase Unwrapping
资源简介
Two Dimensional Phase Unwrapping Theory Algorithms, and Software 书中程序代码
代码片段和文件信息
/*
* brcut.c -- functions for branch cutting
*/
#include
#include
#include “brcut.h“
/* Place a branch cut in the bitflags array from pixel (ab) */
/* to pixel (cd). The bit for the branch cut pixels is */
/* given by the value of “code“. */
void PlaceCut(unsigned char *array int a int b int c int d
int xsize int ysize int code)
{
int i j k ii jj m n istep jstep;
double r;
/* residue location is upper-left corner of 4-square */
if (c > a && a > 0) a++;
else if (c < a && c > 0) c++;
if (d > b && b > 0) b++;
else if (d < b && d > 0) d++;
if (a==c && b==d) {
array[b*xsize + a] |= code;
return;
}
m = (a < c) ? c - a : a - c;
n = (b < d) ? d - b : b - d;
if (m > n) {
istep = (a < c) ? +1 : -1;
r = ((double)(d - b))/((double)(c - a));
for (i=a; i!=c+istep; i+=istep) {
j = b + (i - a)*r + 0.5;
array[j*xsize + i] |= code;
}
}
else { /* n < m */
jstep = (b < d) ? +1 : -1;
r = ((double)(c - a))/((double)(d - b));
for (j=b; j!=d+jstep; j+=jstep) {
i = a + (j - b)*r + 0.5;
array[j*xsize + i] |= code;
}
}
return;
}
/* Return the squared distance between the pixel (ab) and the */
/* nearest border pixel. The border pixels are encoded in the */
/* bitflags array by the value of “border_code“. */
int DistToBorder(unsigned char *bitflags int border_code
int a int b int *ra int *rb int xsize int ysize)
{
int besta bestb found dist2 best_dist2;
int i j k bs;
*ra = *rb = 0;
for (bs=0; bs found = 0;
best_dist2 = 1000000; /* initialize to large value */
/* search boxes of increasing size until border pixel found */
for (j=b - bs; j<=b + bs; j++) {
for (i=a - bs; i<=a + bs; i++) {
k = j*xsize + i;
if (i<=0 || i>=xsize - 1 || j<=0 || j>=ysize - 1
|| (bitflags[k] & border_code)) {
found = 1;
dist2 = (j - b)*(j - b) + (i - a)*(i - a);
if (dist2 < best_dist2) {
best_dist2 = dist2;
besta = i;
bestb = j;
}
}
}
}
if (found) {
*ra = besta;
*rb = bestb;
break;
}
}
return best_dist2;
}
- 上一篇:Kinect运用OpenNI产生点云
- 下一篇:springboot+ajax
相关资源
- model_of_Two_phase_Hybrid_stepping_motor.slx
- ThreePhase_TSC.slx
- The Relationship between Phase Structure and E
- BCS-BEC crossover and quantum phase transition
- Separation of spin angular momenta in focal re
- Phase separation and crystallization of binary
- Phase Separation of Dipolar BEC
- Highly Enantioselective HPLC Separation of 5-M
- 分享自己搭的单相整流器的单极性P
- FLUENT multiphase多相流高级应用
评论
共有 条评论