Révision 32
lsm3D_compile.sh (revision 32) | ||
---|---|---|
7 | 7 |
# -------------------------- |
8 | 8 |
CCPP='g++' |
9 | 9 |
|
10 |
# For MacOS X: |
|
10 |
# For MacOS X you may want to change it:
|
|
11 | 11 |
# --------------------------- |
12 | 12 |
#CCPP='g++-mp-6' |
13 | 13 |
#CCPP='clang++' |
src/lsm_cells.cpp (revision 32) | ||
---|---|---|
4 | 4 |
|
5 | 5 |
To compile : |
6 | 6 |
g++ -o lsm_cells lsm_cells.cpp -O2 -L/usr/X11R6/lib -lm -lpthread -lX11 -fopenmp |
7 |
Need CImg.h and lsm_lib.h |
|
7 |
Needs CImg.h and lsm_lib.h
|
|
8 | 8 |
|
9 | 9 |
To execute : |
10 |
./lsm_cells img img_wat img_contour erosion |
|
10 |
./lsm_cells img img_wat img_contour erosion a b gamma smooth type
|
|
11 | 11 |
|
12 | 12 |
image in .inr or .inr.gz, save in .inr.gz |
13 | 13 |
img : grayscale image of cells (unsigned char) |
14 | 14 |
img_wat : watershed 16bits image (unsigned short) with background label 1 and cells labels >1 |
15 | 15 |
img_contour : binary image with background=1, all cells=0 (unsigned char) |
16 | 16 |
erosion : amount of erosion for each cell in watershed image (int) |
17 |
a : area term (float) --> 0 or 0.5 or 1 (the default is 0.5) |
|
18 |
if negative, the object retracts |
|
19 |
if positive, the object inflates |
|
20 |
b : curvature term (float) --> 0 or 1 (the default is 0) |
|
21 |
gamma : scale parameter (float>0) --> 0.5 or 1 (the default is 1) |
|
22 |
smooth : gaussian blur to apply to the image (int) --> 0 or 1 (the default is 0) |
|
23 |
lsm_type : image, gradient or hessien based evolution --> 'i', 'g' or 'h' (the default is g) |
|
17 | 24 |
*/ |
18 | 25 |
|
19 | 26 |
#include <iostream> |
... | ... | |
357 | 364 |
|
358 | 365 |
int c0=-4; |
359 | 366 |
int erosion=atoi(argv[4]); |
360 |
int marge=10; //10
|
|
367 |
int marge=10; |
|
361 | 368 |
|
362 | 369 |
int lam=10; |
363 |
float alf=0.5;//1
|
|
370 |
float alf=0.5; |
|
364 | 371 |
float beta=0; |
365 | 372 |
float gamma=1; |
366 | 373 |
float smooth=0; |
src/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