50 #include <visp/vpMe.h>
51 #include <visp/vpColVector.h>
52 #include <visp/vpMath.h>
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
78 permute(Type & a, Type & b)
86 droite_cartesienne(point P, point Q)
92 PQ.c = Q.y*P.x - Q.x*P.y;
100 point_intersection(droite D1, droite D2)
105 det = (D1.a*D2.b - D2.a*D1.b);
106 I.x = (D2.c*D1.b - D1.c*D2.b)/det;
107 I.y = (D1.c*D2.a - D2.c*D1.a)/det;
114 double Xmin,
double Ymin,
double Xmax,
double Ymax)
129 permute(point &A, point &B)
144 clipping (point A, point B,
145 double Xmin,
double Ymin,
double Xmax,
double Ymax,
146 point & Ac , point & Bc )
149 D[0].a = 1; D[0].b = 0; D[0].c = -Xmin;
150 D[1].a = 1; D[1].b = 0; D[1].c = -Xmax;
151 D[2].a = 0; D[2].b = 1; D[2].c = -Ymin;
152 D[3].a = 0; D[3].b = 1; D[3].c = -Ymax;
160 AB = droite_cartesienne(A,B);
183 if((code_P[0] | code_P[1])==0000)
197 if((code_P[0] & code_P[1])!=0000)
207 if(code_P[0] != 0000)
210 for(i=0,bit_i=1; !(code_P[0] & bit_i); i++,bit_i<<=1){;}
215 for(i=0,bit_i=1; !(code_P[1] & bit_i); i++,bit_i<<=1){;}
218 P[n] = point_intersection(AB,D[i]);
224 recale(P[n], Xmin,Ymin,Xmax,Ymax);
235 S_relative(point P, point Q,
236 double Xmin,
double Ymin,
double Xmax,
double Ymax)
244 recale(P, Xmin,Ymin,Xmax,Ymax);
245 recale(Q, Xmin,Ymin,Xmax,Ymax);
248 if((std::fabs(P.x-Xmin) <=
vpMath::maximum(std::fabs(P.x),std::fabs(Xmin))*std::numeric_limits<double>::epsilon())
250 (std::fabs(Q.x-Xmax) <=
vpMath::maximum(std::fabs(Q.x),std::fabs(Xmax))*std::numeric_limits<double>::epsilon()))
251 return( fabs(Ymax+Ymin-P.y-Q.y) );
255 if( ( (std::fabs(P.y-Ymin) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon())
257 (std::fabs(Q.y-Ymax) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon()) )
259 ( (std::fabs(Q.y-Ymin) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon())
261 (std::fabs(P.y-Ymax) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon()) ) )
262 return( fabs(Xmax+Xmin-P.x-Q.x) );
265 if( std::fabs(P.x-Xmin) <=
vpMath::maximum(std::fabs(P.x),std::fabs(Xmin))*std::numeric_limits<double>::epsilon()
267 std::fabs(Q.y-Ymax) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon() )
268 return( 1-(Ymax-P.y)*(Q.x-Xmin) );
270 if( std::fabs(P.x-Xmin) <=
vpMath::maximum(std::fabs(P.x),std::fabs(Xmin))*std::numeric_limits<double>::epsilon()
272 std::fabs(Q.y-Ymin) <=
vpMath::maximum(std::fabs(Q.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon() )
273 return( 1-(P.y-Ymin)*(Q.x-Xmin) );
275 if( std::fabs(P.y-Ymin) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymin))*std::numeric_limits<double>::epsilon()
276 && std::fabs(Q.x-Xmax) <=
vpMath::maximum(std::fabs(Q.x),std::fabs(Xmax))*std::numeric_limits<double>::epsilon() )
277 return( 1-(Xmax-P.x)*(Q.y-Ymin) );
279 if( std::fabs(P.y-Ymax) <=
vpMath::maximum(std::fabs(P.y),std::fabs(Ymax))*std::numeric_limits<double>::epsilon()
280 && std::fabs(Q.x-Xmax) <=
vpMath::maximum(std::fabs(Q.x),std::fabs(Xmax))*std::numeric_limits<double>::epsilon())
281 return( 1-(Xmax-P.x)*(Ymax-Q.y) );
284 printf(
"utils_ecm: ERREUR dans S_relative (%f,%f) (%f,%f) %f %f %f %f\n",
285 P.x,P.y,Q.x,Q.y,Xmin,Ymin,Xmax,Ymax);
297 unsigned int i_theta,
300 theta, cos_theta, sin_theta, tan_theta,
301 moitie = ((double)n)/2.0;
306 unsigned int nb_theta = angle.
getRows() ;
308 for(i_theta=0; i_theta<nb_theta; i_theta++)
310 theta = M_PI/180*angle[i_theta];
312 cos_theta = cos(theta);
313 sin_theta = sin(theta);
318 if( std::fabs(angle[i_theta]-90) <=
vpMath::maximum(std::fabs(angle[i_theta]), 90.)*std::numeric_limits<double>::epsilon() )
320 P1.x=0; P1.y=-(int)n;
325 tan_theta = sin_theta/cos_theta;
326 P1.x=-(int)n; P1.y=tan_theta*(-(int)n);
327 Q1.x=n; Q1.y=tan_theta*n;
334 for(i=0,Y=-moitie+0.5 ; i<n ; i++,Y++)
336 for(j=0,X=-moitie+0.5 ; j<n ; j++,X++)
342 if( clipping(P1,Q1, X-0.5,Y-0.5,X+0.5,Y+0.5, P,Q) )
345 v=S_relative(P,Q, X-0.5,Y-0.5,X+0.5,Y+0.5);
378 unsigned int angle_pas ;
379 angle_pas = 180 /
n_mask ;
382 for (
unsigned int i = 0 ; k <
n_mask ; i += angle_pas)
395 std::cout<< std::endl ;
396 std::cout<<
"Moving edges settings " <<std::endl ;
397 std::cout<< std::endl ;
398 std::cout<<
" Size of the convolution masks...."<<
mask_size<<
"x"<<
mask_size<<
" pixels"<<std::endl ;
399 std::cout<<
" Number of masks.................."<<
n_mask<<
" "<<std::endl ;
400 std::cout<<
" Query range +/- J................"<<
range<<
" pixels "<<std::endl ;
401 std::cout<<
" Likelihood test ratio............"<<
threshold<<std::endl ;
402 std::cout<<
" Contrast tolerance +/-..........."<<
mu1 * 100<<
"% and "<<
mu2 * 100<<
"% "<<std::endl ;
403 std::cout<<
" Sample step......................"<<
sample_step<<
" pixels"<<std::endl ;
404 std::cout<<
" Strip............................"<<
strip<<
" pixels "<<std::endl ;
405 std::cout<<
" Min_Samplestep..................."<<
min_samplestep<<
" pixels "<<std::endl ;
407 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
408 std::cout<<
" Aberration......................."<<
aberration<< std::endl ;
409 std::cout<<
" init_aberration.................."<<
init_aberration<<std::endl ;
430 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
466 #ifdef VISP_BUILD_DEPRECATED_FUNCTIONS