From: <ts...@us...> - 2008-08-20 08:39:55
|
Revision: 3885 http://teem.svn.sourceforge.net/teem/?rev=3885&view=rev Author: tststs Date: 2008-08-20 08:40:05 +0000 (Wed, 20 Aug 2008) Log Message: ----------- limn: Replaced angle weighting with area weighting for normal estimation to avoid problems with degenerate triangles. ell: Added some more ELL_2V macros. Modified Paths: -------------- teem/trunk/src/ell/ellMacros.h teem/trunk/src/limn/polydata.c Modified: teem/trunk/src/ell/ellMacros.h =================================================================== --- teem/trunk/src/ell/ellMacros.h 2008-08-12 14:56:02 UTC (rev 3884) +++ teem/trunk/src/ell/ellMacros.h 2008-08-20 08:40:05 UTC (rev 3885) @@ -95,6 +95,29 @@ #define ELL_2V_COPY(v2, v1) \ ((v2)[0] = (v1)[0], (v2)[1] = (v1)[1]) +#define ELL_2V_INCR(v2, v1) \ + ((v2)[0] += (v1)[0], \ + (v2)[1] += (v1)[1]) + +#define ELL_2V_ADD2(v3, v1, v2) \ + ((v3)[0] = (v1)[0] + (v2)[0], \ + (v3)[1] = (v1)[1] + (v2)[1]) + +#define ELL_2V_ADD3(v4, v1, v2, v3) \ + ((v4)[0] = (v1)[0] + (v2)[0] + (v3)[0], \ + (v4)[1] = (v1)[1] + (v2)[1] + (v3)[1]) + +#define ELL_2V_ADD4(v5, v1, v2, v3, v4) \ + ((v5)[0] = (v1)[0] + (v2)[0] + (v3)[0] + (v4)[0], \ + (v5)[1] = (v1)[1] + (v2)[1] + (v3)[1] + (v4)[1]) + +#define ELL_2V_SUB(v3, v1, v2) \ + ((v3)[0] = (v1)[0] - (v2)[0], \ + (v3)[1] = (v1)[1] - (v2)[1]) + +#define ELL_2V_COPY(v2, v1) \ + ((v2)[0] = (v1)[0], (v2)[1] = (v1)[1]) + #define ELL_2V_DOT(v1, v2) ((v1)[0]*(v2)[0] + (v1)[1]*(v2)[1]) #define ELL_2V_LEN(v) (sqrt(ELL_2V_DOT((v),(v)))) Modified: teem/trunk/src/limn/polydata.c =================================================================== --- teem/trunk/src/limn/polydata.c 2008-08-12 14:56:02 UTC (rev 3884) +++ teem/trunk/src/limn/polydata.c 2008-08-20 08:40:05 UTC (rev 3885) @@ -405,17 +405,17 @@ ELL_34V_HOMOG(pos[ii], pld->xyzw + 4*indxLine[ii]); } ELL_3V_SUB(edgeA, pos[1], pos[0]); - ELL_3V_NORM_TT(edgeA, float, edgeA, len); ELL_3V_SUB(edgeB, pos[2], pos[0]); - ELL_3V_NORM_TT(edgeB, float, edgeB, len); ELL_3V_CROSS(norm, edgeA, edgeB); - ELL_3V_NORM_TT(norm, float, norm, len); - ELL_3V_ADD2(sum, edgeA, edgeB); - ELL_3V_SUB(dif, edgeA, edgeB); - /* wght is angle between edges, as per redbook Appendix E */ - wght = 2*AIR_CAST(float, atan2(ELL_3V_LEN(dif), ELL_3V_LEN(sum))); + /* Adding cross products without any normalization is + * equivalent to weighting by triangle area, as proposed + * (among others) by G. Taubin ("Estimating the tensor of + * curvature of a surface from a polyhedral approximation", + * ICCV 1995). This is efficient, avoids trouble with + * degenerate triangles and gives reasonable results in + * practice. */ for (ii=0; ii<3; ii++) { - ELL_3V_SCALE_INCR(pld->norm + 3*indxLine[ii], wght, norm); + ELL_3V_INCR(pld->norm + 3*indxLine[ii], norm); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |