]> Creatis software - creaVtk.git/commitdiff
#3281 creaVtk Feature New Normal - FindAxisEED
authorEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Mon, 22 Jul 2019 14:35:14 +0000 (16:35 +0200)
committerEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Mon, 22 Jul 2019 14:35:14 +0000 (16:35 +0200)
bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbg [new file with mode: 0644]
bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbs [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkDistanceMap.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkDistanceMap.h

diff --git a/bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbg b/bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbg
new file mode 100644 (file)
index 0000000..943080a
--- /dev/null
@@ -0,0 +1,203 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /home/davila/Creatis/C8/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+COMPLEXBOX:TRUE
+COMPLEXBOXNAME:FindAxisEED
+PACKAGENAME:creaVtk
+COMPLEXOUTPUTS:7
+COMPLEX_PORT
+imageOutTmp
+-86.519730:-205.275397:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+imageOutDistanceMap
+67.799086:-204.784844:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+axisLstX
+-12.475387:-203.066620:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+axisLstY
+22.071112:-204.330508:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+axisLstZ
+39.089406:-202.265702:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+finalPointDistanceMap
+-49.262810:-205.322083:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+outLengthPixelsDistanceMap
+-28.377706:-204.106778:-900.000000
+FIN_COMPLEX_PORT
+COMPLEXINPUTS:6
+COMPLEX_PORT
+stdDev
+-28.447633:50.012145:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+averageRadius
+-159.307290:53.037280:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+imageMask
+-106.635422:53.024269:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+slopeDistanceMap
+175.140002:49.789248:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+Point2DistanceMap
+124.204556:49.878387:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+Point1DistanceMap
+77.729781:51.447056:-900.000000
+FIN_COMPLEX_PORT
+BOXES:7
+BOX
+vtk:ImageGaussianSmooth:Box15
+ISEXEC:FALSE
+-86.019292:-54.567937:-900.000000
+-37.119292:-64.567937:-900.000000
+FIN_BOX
+BOX
+itk:BinaryThresholdImageFilter:Box16
+ISEXEC:FALSE
+-69.915319:-77.677020:-900.000000
+-17.740319:-87.677020:-900.000000
+PORT
+InsideValue:"255"
+PORT
+LowerThreshold:"250"
+PORT
+OutsideValue:"0"
+PORT
+UpperThreshold:"1000"
+FIN_BOX
+BOX
+vtk:ImageGaussianSmooth:Box17
+ISEXEC:FALSE
+-152.015620:-95.824068:-900.000000
+-103.115620:-105.824068:-900.000000
+PORT
+StdDevX:"10"
+PORT
+StdDevY:"10"
+PORT
+StdDevZ:"3"
+FIN_BOX
+BOX
+creaVtk:ApplyMask:Box20
+ISEXEC:FALSE
+-32.976315:-121.753349:-900.000000
+4.248685:-131.753349:-900.000000
+FIN_BOX
+BOX
+creaVtk:DistanceMap:Box21
+ISEXEC:FALSE
+-13.775824:-151.205153:-900.000000
+25.424176:-161.205153:-900.000000
+PORT
+Point1:"107 103 382"
+FIN_BOX
+BOX
+std:ConcatStrings:Box30
+ISEXEC:FALSE
+-172.788476:-49.034634:-900.000000
+-133.063476:-59.034634:-900.000000
+PORT
+In1:"10"
+FIN_BOX
+BOX
+std:ConcatStrings:Box31
+ISEXEC:FALSE
+-61.001950:-12.733523:-900.000000
+-21.276950:-22.733523:-900.000000
+PORT
+In1:"10"
+FIN_BOX
+CONNECTIONS:24
+CONNECTION
+Box15:Out:Box16:In
+NumberOfControlPoints:0
+CONNECTION
+Box16:Out:Box17:In
+NumberOfControlPoints:0
+CONNECTION
+Box17:Out:Box20:Image
+NumberOfControlPoints:0
+CONNECTION
+Box16:Out:Box20:Mask
+NumberOfControlPoints:0
+CONNECTION
+Box20:Out:Box21:In
+NumberOfControlPoints:0
+CONNECTION
+Box30:Out:Box17:StdDevX
+NumberOfControlPoints:0
+CONNECTION
+Box30:Out:Box17:StdDevY
+NumberOfControlPoints:0
+CONNECTION
+Box30:Out:Box21:AverageRadius
+NumberOfControlPoints:0
+CONNECTION
+Box31:Out:Box15:StdDevX
+NumberOfControlPoints:0
+CONNECTION
+Box31:Out:Box15:StdDevY
+NumberOfControlPoints:0
+CONNECTION
+Box31:Out:Box15:StdDevZ
+NumberOfControlPoints:0
+CONNECTION
+stdDev:stdDev:Box31:In1
+NumberOfControlPoints:0
+CONNECTION
+averageRadius:averageRadius:Box30:In1
+NumberOfControlPoints:0
+CONNECTION
+imageMask:imageMask:Box15:In
+NumberOfControlPoints:0
+CONNECTION
+slopeDistanceMap:slopeDistanceMap:Box21:Slope
+NumberOfControlPoints:0
+CONNECTION
+Box16:Out:imageOutTmp:imageOutTmp
+NumberOfControlPoints:0
+CONNECTION
+Box21:Out:imageOutDistanceMap:imageOutDistanceMap
+NumberOfControlPoints:0
+CONNECTION
+Box21:LstPathXOut:axisLstX:axisLstX
+NumberOfControlPoints:0
+CONNECTION
+Box21:LstPathYOut:axisLstY:axisLstY
+NumberOfControlPoints:0
+CONNECTION
+Box21:LstPathZOut:axisLstZ:axisLstZ
+NumberOfControlPoints:0
+CONNECTION
+Box21:FinalPoint:finalPointDistanceMap:finalPointDistanceMap
+NumberOfControlPoints:0
+CONNECTION
+Point2DistanceMap:Point2DistanceMap:Box21:Point2
+NumberOfControlPoints:0
+CONNECTION
+Point1DistanceMap:Point1DistanceMap:Box21:Point1
+NumberOfControlPoints:0
+CONNECTION
+Box21:LengthPixels:outLengthPixelsDistanceMap:outLengthPixelsDistanceMap
+NumberOfControlPoints:0
+APP_END
diff --git a/bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbs b/bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbs
new file mode 100644 (file)
index 0000000..84424b2
--- /dev/null
@@ -0,0 +1,75 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box)
+# - /home/davila/Creatis/C8/creatools_source/creaVtk/bbtk_creaVtk_PKG/bbs/boxes/FindAxisEED.bbs
+# ----------------------------------
+
+include std
+include itkvtk
+include vtk
+include itk
+include creaVtk
+include std
+
+define FindAxisEED creaVtk
+
+author "Author ??"
+description "Description ??"
+
+category "<VOID>"
+
+new vtk:ImageGaussianSmooth Box15
+
+new itk:BinaryThresholdImageFilter Box16
+  set Box16.InsideValue "255"
+  set Box16.LowerThreshold "250"
+  set Box16.OutsideValue "0"
+  set Box16.UpperThreshold "1000"
+
+new vtk:ImageGaussianSmooth Box17
+  set Box17.StdDevX "10"
+  set Box17.StdDevY "10"
+  set Box17.StdDevZ "3"
+
+new creaVtk:ApplyMask Box20
+
+new creaVtk:DistanceMap Box21
+  set Box21.Point1 "107 103 382"
+
+new std:ConcatStrings Box30
+  set Box30.In1 "10"
+
+new std:ConcatStrings Box31
+  set Box31.In1 "10"
+
+
+connect Box15.Out Box16.In
+connect Box16.Out Box17.In
+connect Box17.Out Box20.Image
+connect Box16.Out Box20.Mask
+connect Box20.Out Box21.In
+connect Box30.Out Box17.StdDevX
+connect Box30.Out Box17.StdDevY
+connect Box30.Out Box21.AverageRadius
+connect Box31.Out Box15.StdDevX
+connect Box31.Out Box15.StdDevY
+connect Box31.Out Box15.StdDevZ
+
+# Complex input ports
+input stdDev Box31.In1 " "
+input averageRadius Box30.In1 " "
+input imageMask Box15.In " "
+input slopeDistanceMap Box21.Slope " "
+input Point2DistanceMap Box21.Point2 " "
+input Point1DistanceMap Box21.Point1 " "
+
+# Complex output ports
+output imageOutTmp Box16.Out " "
+output imageOutDistanceMap Box21.Out " "
+output axisLstX Box21.LstPathXOut " "
+output axisLstY Box21.LstPathYOut " "
+output axisLstZ Box21.LstPathZOut " "
+output finalPointDistanceMap Box21.FinalPoint " "
+output outLengthPixelsDistanceMap Box21.LengthPixels " "
+
+
+endefine
index 787c1efa5e3d9033935458369b5534768066adec..fae5840f0958a5319805039e279f9dd58e35c5c2 100644 (file)
@@ -3,6 +3,9 @@
 //===== 
 #include "bbcreaVtkDistanceMap.h"
 #include "bbcreaVtkPackage.h"
+
+#include "creaVtk_MACROS.h"
+
 namespace bbcreaVtk
 {
 
@@ -29,14 +32,17 @@ void DistanceMap::Process()
        if ( (bbGetInputIn()!=NULL) && (bbGetInputPoint1().size()==3) )
        {
 
-               int     ext[6];
-               int     dim[3];
+               int             ext[6];
+               int             dim[3];
+               long int        dimX,dimXY;
                double  spc[3];
                bbGetInputIn()->GetSpacing(spc);
                bbGetInputIn()->GetExtent(ext);
-               dim[0]= ext[1]-ext[0]+1;
-               dim[1]= ext[3]-ext[2]+1;
-               dim[2]= ext[5]-ext[4]+1;
+               dim[0]  = ext[1]-ext[0]+1;
+               dim[1]  = ext[3]-ext[2]+1;
+               dim[2]  = ext[5]-ext[4]+1;
+               dimX    = dim[0];
+               dimXY   = dim[0]*dim[1];
                if (imageoutput!=NULL) 
                {
                        imageoutput->Delete();
@@ -74,16 +80,11 @@ void DistanceMap::Process()
                double depth=0;
                int px,py,pz;           
                int pxOut,pyOut,pzOut;  
+               double tmpValue;
 
 
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
-printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
+               DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn())
+               DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput)
 
                while (lst1X.size()>0)
                {
@@ -91,13 +92,18 @@ printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
                        size=lst1X.size();
                        for (i=0;i<size;i++)
                        {
-                               glIn=bbGetInputIn()->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
+                               GETVALUE2_VTK_CREA(glIn,pIn,stIn, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
+
+//                             glIn=bbGetInputIn()->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
                                if (glIn!=0)
                                {
-                                       glOut=imageoutput->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
+                                       GETVALUE2_VTK_CREA(glOut,pOut,stOut, lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
+//                                     glOut=imageoutput->GetScalarComponentAsDouble( lst1X[i], lst1Y[i], lst1Z[i], 0);
                                        if (glOut==0)
                                        {
-                                               imageoutput->SetScalarComponentFromDouble( lst1X[i], lst1Y[i], lst1Z[i], 0, depth+(255-glIn));
+                                               tmpValue        =       depth  +  (255-glIn)*bbGetInputAverageRadius()*2;
+                                               SETVALUE2_VTK_CREA(tmpValue,pOut,stOut,  lst1X[i] + lst1Y[i]*dimX + lst1Z[i]*dimXY )
+//                                             imageoutput->SetScalarComponentFromDouble( lst1X[i], lst1Y[i], lst1Z[i], 0, depth+(255-glIn)*bbGetInputAverageRadius()*2);
                                                pxOut=lst1X[i]; pyOut=lst1Y[i]; pzOut=lst1Z[i];
 
 
@@ -110,7 +116,12 @@ printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
                                                                        if (!( (px==lst1X[i]) && (py==lst1Y[i]) && (pz==lst1Z[i]) )) 
                                                                        {
                                                                                if ((px>=0) && (px<dim[0]) && (py>=0) && (py<dim[1]) &&  (pz>=0) && (pz<dim[2]) )
-                                                                                       { glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0); } else { glOut=-1; }
+                                                                               { 
+                                                                                       GETVALUE2_VTK_CREA(glOut,pOut,stOut, px + py*dimX + pz*dimXY )
+//                                                                                     glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0); 
+                                                                               } else { 
+                                                                                       glOut=-1; 
+                                                                               } // if px py pz  inside the image
                                                                                if (glOut==0) { lst2X.push_back(px); lst2Y.push_back(  py ); lst2Z.push_back(  pz ); }
                                                                        } // if 
                                                                } // for kk
@@ -173,7 +184,6 @@ printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
                int pxOutBack;
                int pyOutBack;
                int pzOutBack;
-               int length=0;
                while (ok==true)
                {       
                        ok2=false;
@@ -185,7 +195,8 @@ printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
                                        {
                                                if ((px>=0) && (px<dim[0]) && (py>=0) && (py<dim[1]) && (pz>=0) && (pz<dim[2]) )
                                                { 
-                                                               glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0); 
+                                                               GETVALUE2_VTK_CREA(glOut,pOut,stOut, px + py*dimX + pz*dimXY )
+//                                                             glOut=imageoutput->GetScalarComponentAsDouble( px,py,pz , 0); 
                                                                if ( (glOut<min) && (glOut!=0) )
                                                                {
                                                                        min                     = glOut;
@@ -207,7 +218,6 @@ printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
                                lstPathXOut.push_back( pxOut );
                                lstPathYOut.push_back( pyOut );
                                lstPathZOut.push_back( pzOut );
-                               length++;
                        } else {
                                ok=false;
                        }
@@ -215,7 +225,19 @@ printf("EED Warnning!  DistanceMap::Process    Clean Ponter Image......\n");
 
                bbSetOutputOut( imageoutput );
                bbSetOutputFinalPoint( lstPointOut );
-               bbSetOutputLength( length );
+               bbSetOutputLengthPixels( lstPathXOut.size() );
+
+               // invert list of points
+               size=lstPathXOut.size();
+               long int size2=size/2;
+               int tmp;        
+               for (i=0; i<size2;i++)
+               {
+                       tmp= lstPathXOut[i]; lstPathXOut[i]=lstPathXOut[size-1-i]; lstPathXOut[size-1-i]=tmp;
+                       tmp= lstPathYOut[i]; lstPathYOut[i]=lstPathYOut[size-1-i]; lstPathYOut[size-1-i]=tmp;
+                       tmp= lstPathZOut[i]; lstPathZOut[i]=lstPathZOut[size-1-i]; lstPathZOut[size-1-i]=tmp;
+               } // for invert list            
+
                bbSetOutputLstPathXOut( lstPathXOut );
                bbSetOutputLstPathYOut( lstPathYOut );
                bbSetOutputLstPathZOut( lstPathZOut );
@@ -233,6 +255,7 @@ void DistanceMap::bbUserSetDefaultValues()
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
        bbSetInputIn(NULL);
+       bbSetInputAverageRadius(10);
        bbSetInputSlope(10);
        imageoutput=NULL;
   
index 9fc412ac7259ebb802a070003a55f45e589b3a46..ffa199abc4b3943b33128a0298af857129e7d336 100644 (file)
@@ -24,11 +24,12 @@ class bbcreaVtk_EXPORT DistanceMap
 
   BBTK_DECLARE_INPUT(In,vtkImageData*);
   BBTK_DECLARE_INPUT(Slope,double);
+  BBTK_DECLARE_INPUT(AverageRadius,double);
   BBTK_DECLARE_INPUT(Point1, std::vector<int>);
   BBTK_DECLARE_INPUT(Point2, std::vector<int>);
 
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
-  BBTK_DECLARE_OUTPUT(Length, int );
+  BBTK_DECLARE_OUTPUT(LengthPixels, int );
   BBTK_DECLARE_OUTPUT(FinalPoint,std::vector<int>);
   BBTK_DECLARE_OUTPUT(LstPathXOut,std::vector<int>);
   BBTK_DECLARE_OUTPUT(LstPathYOut,std::vector<int>);
@@ -52,11 +53,12 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(DistanceMap,bbtk::AtomicBlackBox);
 
     BBTK_INPUT(DistanceMap,In,"Input image",vtkImageData*,"");
     BBTK_INPUT(DistanceMap,Slope,"(default 10) Slope",double,"");
+    BBTK_INPUT(DistanceMap,AverageRadius,"(default 10) Average Radius of the tube",double,"");
     BBTK_INPUT(DistanceMap,Point1,"Start point",std::vector<int>,"");
     BBTK_INPUT(DistanceMap,Point2,"End point (There is no guarantee of reaching this point.)",std::vector<int>,"");
 
     BBTK_OUTPUT(DistanceMap,Out,"Output image",vtkImageData*,"");
-    BBTK_OUTPUT(DistanceMap,Length,"Path Length",int,"");
+    BBTK_OUTPUT(DistanceMap,LengthPixels,"Path Length",int,"");
     BBTK_OUTPUT(DistanceMap,FinalPoint,"Final Point",std::vector<int>,"");
     BBTK_OUTPUT(DistanceMap,LstPathXOut,"Vector path X",std::vector<int>,"");
     BBTK_OUTPUT(DistanceMap,LstPathYOut,"Vector path Y",std::vector<int>,"");