Révision 32 src/lsm_lib.h
lsm_lib.h (revision 32) | ||
---|---|---|
513 | 513 |
CImg<float> K=curvature2(N); |
514 | 514 |
CImg<float> L=laplacian(u); |
515 | 515 |
float term=0; |
516 |
int xmax=u._width; |
|
517 |
int ymax=u._height; |
|
518 |
int zmax=u._depth; |
|
519 |
int c0=-4; |
|
516 | 520 |
|
517 |
|
|
518 | 521 |
cimg_forXYZ(u,x,y,z) |
519 | 522 |
{ |
520 | 523 |
int xb=x+min_list[0]; |
... | ... | |
542 | 545 |
//penalizing term |
543 | 546 |
term=(L(x,y,z)-K(x,y,z))*mu; |
544 | 547 |
} |
545 |
|
|
548 |
// computing the evolution |
|
546 | 549 |
u(x,y,z)=u(x,y,z) + term*dt; |
550 |
// box boundary regularisation |
|
551 |
if ((x==0) or (x==xmax) or (x==1) or (x==xmax-1) or(y==0) or (y==ymax)or(y==1) or (y==ymax-1) or (z==0) or (z==zmax)or (z==1) or (z==zmax-1)) |
|
552 |
{u(x,y,z)=c0;} |
|
547 | 553 |
} |
548 | 554 |
return u; |
549 | 555 |
} |
550 |
|
|
551 |
//Evolution AK2 contour INTERRACT |
|
552 |
//------------------------------------------------------------------------- |
|
553 |
CImg<float> evolution_AK2_contour_interact(CImg<float> u, CImg<float> const & g, CImgList<float> const & gg, CImg<float> const & h, int lam, float mu, float alf, int beta, float epsilon, int dt, CImg<unsigned char> const & free, vector<int>min_list) |
|
554 |
{ |
|
555 |
CImg<float> diracU=Dirac(u,epsilon); |
|
556 |
CImgList<float> N=normal_vector(u); |
|
557 |
CImg<float> K=curvature2(N); |
|
558 |
CImg<float> L=laplacian(u); |
|
559 |
float term=0; |
|
560 |
|
|
561 |
cimg_forXYZ(u,x,y,z) |
|
562 |
{ |
|
563 |
int xb=x+min_list[0]; |
|
564 |
int yb=y+min_list[1]; |
|
565 |
int zb=z+min_list[2]; |
|
566 |
term=0; |
|
567 |
if(free(xb,yb,zb)==0) |
|
568 |
{ |
|
569 |
if (diracU(x,y,z)!=0) |
|
570 |
{ |
|
571 |
//weighted length term |
|
572 |
if(lam!=0) |
|
573 |
{term=( gg(0,xb,yb,zb)*N(0,x,y,z) + gg(1,xb,yb,zb)*N(1,x,y,z) + gg(2,xb,yb,zb)*N(2,x,y,z) + (g(xb,yb,zb)*K(x,y,z))) *lam;} |
|
574 |
//length term |
|
575 |
if(beta!=0) |
|
576 |
{term=term + K(x,y,z)*beta;} |
|
577 |
//weighted area term |
|
578 |
if(alf!=0) |
|
579 |
{term=term + h(xb,yb,zb)*alf;} |
|
580 |
//regularization |
|
581 |
term=term*diracU(x,y,z); |
|
582 |
//penalizing term |
|
583 |
term=term + (L(x,y,z)-K(x,y,z))*mu; |
|
584 |
} |
|
585 |
else |
|
586 |
{ |
|
587 |
//penalizing term |
|
588 |
term=(L(x,y,z)-K(x,y,z))*mu; |
|
589 |
} |
|
590 |
u(x,y,z)=u(x,y,z) + term*dt; |
|
591 |
} |
|
592 |
} |
|
593 |
return u; |
|
594 |
} |
Formats disponibles : Unified diff