--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.6 BBG BlackBox Diagram file
+# - /Users/davila/Borrame/borrame/exampleBifurcationInSkeletonization.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+EXPORTFORMAT:0
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:32
+BOX
+vtk:LoadHola:Box00
+ISEXEC:FALSE
+-9.167511:66.591022:-900.000000
+12.382489:64.091022:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ImageChangeInformation:Box01
+ISEXEC:FALSE
+-10.262309:57.558945:-900.000000
+12.887691:55.058945:-900.000000
+FIN_BOX
+BOX
+itk:TubularStructures_Sato:Box02
+ISEXEC:FALSE
+-5.211333:42.018469:-900.000000
+17.583667:39.518469:-900.000000
+FIN_BOX
+BOX
+vtk:RescaleSlopeIntercept:Box03
+ISEXEC:FALSE
+13.858995:50.177799:-900.000000
+36.683995:47.677799:-900.000000
+PORT
+OutputFormat:"VTK_DOUBLE"
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box04
+ISEXEC:FALSE
+-57.723979:9.063455:-900.000000
+-15.603979:6.563455:-900.000000
+PORT
+WinTitle:"Image"
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+vtk:RescaleSlopeIntercept:Box05
+ISEXEC:FALSE
+-2.038469:28.109709:-900.000000
+20.786531:25.609709:-900.000000
+PORT
+A:"0"
+PORT
+B:"1000"
+PORT
+OutputFormat:"VTK_SHORT"
+PORT
+Type:"2"
+FIN_BOX
+BOX
+creaVtk:OutputWindow:Box06
+ISEXEC:TRUE
+-31.225434:-121.881072:-900.000000
+-9.170434:-124.381072:-900.000000
+FIN_BOX
+BOX
+wx:LayoutSplit:Box07
+ISEXEC:TRUE
+-3.822047:-121.355662:-900.000000
+20.697953:-123.855662:-900.000000
+PORT
+Orientation:"H"
+PORT
+Proportion:"10"
+FIN_BOX
+BOX
+wx:LayoutTab:Box08
+ISEXEC:FALSE
+19.592768:-103.710167:-900.000000
+54.672768:-106.210167:-900.000000
+FIN_BOX
+BOX
+itk:ThinningImageFilter3D:Box09
+ISEXEC:FALSE
+18.200046:8.882897:-900.000000
+40.955046:6.382897:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box10
+ISEXEC:FALSE
+68.096460:-39.104525:-900.000000
+110.216460:-41.604525:-900.000000
+PORT
+WinTitle:"Skeleton"
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+wx:LayoutLine:Box11
+ISEXEC:FALSE
+-19.773286:-103.998153:-900.000000
+15.306714:-106.498153:-900.000000
+FIN_BOX
+BOX
+creaVtk:ImageThreshold:Box12
+ISEXEC:FALSE
+-6.810593:16.348335:-900.000000
+15.369407:13.848335:-900.000000
+PORT
+InValue:"255"
+PORT
+Lower:"200"
+PORT
+OutValue:"0"
+PORT
+Upper:"10000"
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box13
+ISEXEC:FALSE
+22.806728:-51.376450:-900.000000
+64.926728:-53.876450:-900.000000
+PORT
+WinTitle:"Tubular"
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+creaMaracasVisu:ColorLayerImageView2:Box14
+ISEXEC:FALSE
+-53.055532:-21.631285:-900.000000
+-23.255532:-24.131285:-900.000000
+PORT
+ColorBarPosition:"-1000 -1000"
+PORT
+Interpolation:"false"
+PORT
+lstTransparenceBoundaries:"0"
+FIN_BOX
+BOX
+wx:Slider:Box15
+ISEXEC:FALSE
+50.310881:4.276096:-900.000000
+81.870881:1.776096:-900.000000
+PORT
+In:"0"
+PORT
+Label:"true"
+PORT
+Max:"100"
+PORT
+Min:"0"
+PORT
+ReactiveOnTrack:"true"
+PORT
+Title:"Skeleton opacity (Thinning)"
+FIN_BOX
+BOX
+creaMaracasVisu:ColorLayerImageView2:Box16
+ISEXEC:FALSE
+20.153764:-24.204351:-900.000000
+49.953764:-26.704351:-900.000000
+PORT
+ColorBarPosition:"-1000 -1000"
+PORT
+Interpolation:"false"
+PORT
+lstBaseColor:"0 0 0 0 0 1"
+PORT
+lstGreyLevelBoundaries:"0 128 255"
+PORT
+lstTransparenceBoundaries:"0"
+FIN_BOX
+BOX
+wx:Slider:Box17
+ISEXEC:FALSE
+-48.990366:-6.992147:-900.000000
+-17.430366:-9.492147:-900.000000
+PORT
+In:"0"
+PORT
+Label:"true"
+PORT
+Max:"100"
+PORT
+Min:"0"
+PORT
+ReactiveOnTrack:"true"
+PORT
+Title:"Tubular opacity"
+FIN_BOX
+BOX
+creaVtk:BifurcationsInSkeletonization:Box18
+ISEXEC:FALSE
+-58.342163:-30.130769:-900.000000
+-34.957163:-32.630769:-900.000000
+PORT
+LstX:"9"
+PORT
+LstY:"97"
+PORT
+LstZ:"106"
+FIN_BOX
+BOX
+vtk:SphereList:Box19
+ISEXEC:FALSE
+-83.338183:-118.380489:-900.000000
+-61.743183:-120.880489:-900.000000
+PORT
+lstRadio:"1"
+FIN_BOX
+BOX
+std:ConcatStrings:Box20
+ISEXEC:FALSE
+-97.432165:-50.752140:-900.000000
+-74.672165:-53.252140:-900.000000
+FIN_BOX
+BOX
+std:ConcatStrings:Box21
+ISEXEC:FALSE
+-71.888277:-50.148082:-900.000000
+-49.128277:-52.648082:-900.000000
+FIN_BOX
+BOX
+std:ConcatStrings:Box22
+ISEXEC:FALSE
+-46.561018:-48.867175:-900.000000
+-23.801018:-51.367175:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box23
+ISEXEC:FALSE
+-32.007861:-79.389845:-900.000000
+10.112139:-81.889845:-900.000000
+PORT
+WinTitle:"tmpImage"
+PORT
+nTypeView:"6 1 2 0"
+FIN_BOX
+BOX
+std:Div:Box24
+ISEXEC:FALSE
+-43.062937:-58.663683:-900.000000
+-22.137937:-61.163683:-900.000000
+PORT
+In2:"100"
+FIN_BOX
+BOX
+itk:ImageProperties:Box25
+ISEXEC:FALSE
+-95.525017:-15.066775:-900.000000
+-73.305017:-17.566775:-900.000000
+FIN_BOX
+BOX
+vtk:RescaleSlopeIntercept:Box27
+ISEXEC:FALSE
+17.973950:-0.874838:-900.000000
+40.798950:-3.374838:-900.000000
+PORT
+A:"0"
+PORT
+B:"255"
+PORT
+OutputFormat:"VTK_SHORT"
+PORT
+Type:"2"
+FIN_BOX
+BOX
+std:VectorFilterDouble:Box28
+ISEXEC:FALSE
+-54.381435:-95.421783:-900.000000
+-28.101435:-97.921783:-900.000000
+PORT
+Type:"0"
+FIN_BOX
+BOX
+itk:TubularStructures_Frangi:Box30
+ISEXEC:FALSE
+26.145762:41.613055:-900.000000
+49.105762:39.113055:-900.000000
+PORT
+NumberOfSigmaSteps:"4"
+PORT
+SigmaMaximum:"1"
+FIN_BOX
+BOX
+wx:Slider:Box31
+ISEXEC:FALSE
+-71.677651:32.155146:-900.000000
+-40.117651:29.655146:-900.000000
+PORT
+In:"16"
+PORT
+Label:"true"
+PORT
+Max:"1000"
+PORT
+Min:"1"
+PORT
+Title:"Threshold after Tubular segmentation"
+FIN_BOX
+BOX
+std:MultipleInputs:Box32
+ISEXEC:FALSE
+-66.455144:-14.529181:-900.000000
+-44.485144:-17.029181:-900.000000
+FIN_BOX
+BOX
+creaVtk:BestPoint:Box33
+ISEXEC:FALSE
+-52.237601:-38.870747:-900.000000
+-30.747601:-41.370747:-900.000000
+PORT
+BoxSize:"3"
+PORT
+Type:"1"
+FIN_BOX
+CONNECTIONS:56
+CONNECTION
+Box00:Out:Box01:In
+NumberOfControlPoints:0
+CONNECTION
+Box01:Out:Box03:In
+NumberOfControlPoints:0
+CONNECTION
+Box03:Out:Box02:In
+NumberOfControlPoints:0
+CONNECTION
+Box01:Out:Box04:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:Widget:Box08:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box09:Out:Box10:In
+NumberOfControlPoints:0
+CONNECTION
+Box08:Widget:Box07:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box11:Widget:Box07:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box12:Out:Box09:In
+NumberOfControlPoints:0
+CONNECTION
+Box12:Out:Box13:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:wxVtkBaseView2:Box14:WxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box04:wxVtkBaseView3:Box14:WxVtkBaseView1
+NumberOfControlPoints:0
+CONNECTION
+Box04:wxVtkBaseView4:Box14:WxVtkBaseView2
+NumberOfControlPoints:0
+CONNECTION
+Box12:Out:Box14:In
+NumberOfControlPoints:0
+CONNECTION
+Box15:Widget:Box11:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box10:Widget:Box08:Widget5
+NumberOfControlPoints:0
+CONNECTION
+Box13:Widget:Box08:Widget3
+NumberOfControlPoints:0
+CONNECTION
+Box04:wxVtkBaseView2:Box16:WxVtkBaseView
+NumberOfControlPoints:0
+CONNECTION
+Box04:wxVtkBaseView3:Box16:WxVtkBaseView1
+NumberOfControlPoints:0
+CONNECTION
+Box04:wxVtkBaseView4:Box16:WxVtkBaseView2
+NumberOfControlPoints:0
+CONNECTION
+Box15:BoxChange:Box16:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box15:Out:Box16:Opacity
+NumberOfControlPoints:0
+CONNECTION
+Box17:Widget:Box11:Widget4
+NumberOfControlPoints:0
+CONNECTION
+Box17:Out:Box14:Opacity
+NumberOfControlPoints:0
+CONNECTION
+Box04:Renderer1:Box19:Renderer
+NumberOfControlPoints:0
+CONNECTION
+Box18:Out:Box23:In
+NumberOfControlPoints:0
+CONNECTION
+Box23:Widget:Box08:Widget7
+NumberOfControlPoints:0
+CONNECTION
+Box09:Out:Box18:In
+NumberOfControlPoints:0
+CONNECTION
+Box15:Out:Box24:In1
+NumberOfControlPoints:0
+CONNECTION
+Box24:Out:Box19:Opacity
+NumberOfControlPoints:0
+CONNECTION
+Box15:BoxChange:Box19:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box01:Out:Box25:In
+NumberOfControlPoints:0
+CONNECTION
+Box25:Spacing:Box19:Spacing
+NumberOfControlPoints:0
+CONNECTION
+Box09:Out:Box27:In
+NumberOfControlPoints:0
+CONNECTION
+Box27:Out:Box16:In
+NumberOfControlPoints:0
+CONNECTION
+Box20:Out:Box28:In0
+NumberOfControlPoints:0
+CONNECTION
+Box21:Out:Box28:In1
+NumberOfControlPoints:0
+CONNECTION
+Box22:Out:Box28:In2
+NumberOfControlPoints:0
+CONNECTION
+Box28:Out0:Box19:lstPointX
+NumberOfControlPoints:0
+CONNECTION
+Box28:Out1:Box19:lstPointY
+NumberOfControlPoints:0
+CONNECTION
+Box28:Out2:Box19:lstPointZ
+NumberOfControlPoints:0
+CONNECTION
+Box03:Out:Box30:In
+NumberOfControlPoints:0
+CONNECTION
+Box30:Out:Box05:In
+NumberOfControlPoints:0
+CONNECTION
+Box05:Out:Box12:In
+NumberOfControlPoints:0
+CONNECTION
+Box31:Out:Box12:Lower
+NumberOfControlPoints:0
+CONNECTION
+Box31:Widget:Box11:Widget1
+NumberOfControlPoints:0
+CONNECTION
+Box31:BoxChange:Box32:In1
+NumberOfControlPoints:0
+CONNECTION
+Box17:BoxChange:Box32:In2
+NumberOfControlPoints:0
+CONNECTION
+Box32:BoxChange:Box14:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box18:OutLstX:Box33:InLstX
+NumberOfControlPoints:0
+CONNECTION
+Box18:OutLstY:Box33:InLstY
+NumberOfControlPoints:0
+CONNECTION
+Box18:OutLstZ:Box33:InLstZ
+NumberOfControlPoints:0
+CONNECTION
+Box05:Out:Box33:In
+NumberOfControlPoints:0
+CONNECTION
+Box33:OutLstX:Box20:In1
+NumberOfControlPoints:0
+CONNECTION
+Box33:OutLstY:Box21:In1
+NumberOfControlPoints:0
+CONNECTION
+Box33:OutLstZ:Box22:In1
+NumberOfControlPoints:0
+APP_END
--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.6 BBS BlackBox Script
+# - /Users/davila/Borrame/borrame/exampleBifurcationInSkeletonization.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include vtk
+include creaMaracasVisu
+include itk
+include creaVtk
+include wx
+include std
+
+author "Author ??"
+description "Description ??"
+category "<VOID>"
+
+new vtk:LoadHola Box00
+
+new creaMaracasVisu:ImageChangeInformation Box01
+
+new itk:TubularStructures_Sato Box02
+
+new vtk:RescaleSlopeIntercept Box03
+ set Box03.OutputFormat "VTK_DOUBLE"
+
+new creaMaracasVisu:ViewerNV Box04
+ set Box04.WinTitle "Image"
+ set Box04.nTypeView "6 1 2 0"
+
+new vtk:RescaleSlopeIntercept Box05
+ set Box05.A "0"
+ set Box05.B "1000"
+ set Box05.OutputFormat "VTK_SHORT"
+ set Box05.Type "2"
+
+new creaVtk:OutputWindow Box06
+
+new wx:LayoutSplit Box07
+ set Box07.Orientation "H"
+ set Box07.Proportion "10"
+
+new wx:LayoutTab Box08
+
+new itk:ThinningImageFilter3D Box09
+
+new creaMaracasVisu:ViewerNV Box10
+ set Box10.WinTitle "Skeleton"
+ set Box10.nTypeView "6 1 2 0"
+
+new wx:LayoutLine Box11
+
+new creaVtk:ImageThreshold Box12
+ set Box12.InValue "255"
+ set Box12.Lower "200"
+ set Box12.OutValue "0"
+ set Box12.Upper "10000"
+
+new creaMaracasVisu:ViewerNV Box13
+ set Box13.WinTitle "Tubular"
+ set Box13.nTypeView "6 1 2 0"
+
+new creaMaracasVisu:ColorLayerImageView2 Box14
+ set Box14.ColorBarPosition "-1000 -1000"
+ set Box14.Interpolation "false"
+ set Box14.lstTransparenceBoundaries "0"
+
+new wx:Slider Box15
+ set Box15.In "0"
+ set Box15.Label "true"
+ set Box15.Max "100"
+ set Box15.Min "0"
+ set Box15.ReactiveOnTrack "true"
+ set Box15.Title "Skeleton opacity (Thinning)"
+
+new creaMaracasVisu:ColorLayerImageView2 Box16
+ set Box16.ColorBarPosition "-1000 -1000"
+ set Box16.Interpolation "false"
+ set Box16.lstBaseColor "0 0 0 0 0 1"
+ set Box16.lstGreyLevelBoundaries "0 128 255"
+ set Box16.lstTransparenceBoundaries "0"
+
+new wx:Slider Box17
+ set Box17.In "0"
+ set Box17.Label "true"
+ set Box17.Max "100"
+ set Box17.Min "0"
+ set Box17.ReactiveOnTrack "true"
+ set Box17.Title "Tubular opacity"
+
+new creaVtk:BifurcationsInSkeletonization Box18
+ set Box18.LstX "9"
+ set Box18.LstY "97"
+ set Box18.LstZ "106"
+
+new vtk:SphereList Box19
+ set Box19.lstRadio "1"
+
+new std:ConcatStrings Box20
+
+new std:ConcatStrings Box21
+
+new std:ConcatStrings Box22
+
+new creaMaracasVisu:ViewerNV Box23
+ set Box23.WinTitle "tmpImage"
+ set Box23.nTypeView "6 1 2 0"
+
+new std:Div Box24
+ set Box24.In2 "100"
+
+new itk:ImageProperties Box25
+
+new vtk:RescaleSlopeIntercept Box27
+ set Box27.A "0"
+ set Box27.B "255"
+ set Box27.OutputFormat "VTK_SHORT"
+ set Box27.Type "2"
+
+new std:VectorFilterDouble Box28
+ set Box28.Type "0"
+
+new itk:TubularStructures_Frangi Box30
+ set Box30.NumberOfSigmaSteps "4"
+ set Box30.SigmaMaximum "1"
+
+new wx:Slider Box31
+ set Box31.In "16"
+ set Box31.Label "true"
+ set Box31.Max "1000"
+ set Box31.Min "1"
+ set Box31.Title "Threshold after Tubular segmentation"
+
+new std:MultipleInputs Box32
+
+new creaVtk:BestPoint Box33
+ set Box33.BoxSize "3"
+ set Box33.Type "1"
+
+
+connect Box00.Out Box01.In
+
+connect Box01.Out Box03.In
+
+connect Box03.Out Box02.In
+
+connect Box01.Out Box04.In
+
+connect Box04.Widget Box08.Widget2
+
+connect Box09.Out Box10.In
+
+connect Box08.Widget Box07.Widget2
+
+connect Box11.Widget Box07.Widget1
+
+connect Box12.Out Box09.In
+
+connect Box12.Out Box13.In
+
+connect Box04.wxVtkBaseView2 Box14.WxVtkBaseView
+
+connect Box04.wxVtkBaseView3 Box14.WxVtkBaseView1
+
+connect Box04.wxVtkBaseView4 Box14.WxVtkBaseView2
+
+connect Box12.Out Box14.In
+
+connect Box15.Widget Box11.Widget2
+
+connect Box10.Widget Box08.Widget5
+
+connect Box13.Widget Box08.Widget3
+
+connect Box04.wxVtkBaseView2 Box16.WxVtkBaseView
+
+connect Box04.wxVtkBaseView3 Box16.WxVtkBaseView1
+
+connect Box04.wxVtkBaseView4 Box16.WxVtkBaseView2
+
+connect Box15.BoxChange Box16.BoxExecute
+
+connect Box15.Out Box16.Opacity
+
+connect Box17.Widget Box11.Widget4
+
+connect Box17.Out Box14.Opacity
+
+connect Box04.Renderer1 Box19.Renderer
+
+connect Box18.Out Box23.In
+
+connect Box23.Widget Box08.Widget7
+
+connect Box09.Out Box18.In
+
+connect Box15.Out Box24.In1
+
+connect Box24.Out Box19.Opacity
+
+connect Box15.BoxChange Box19.BoxExecute
+
+connect Box01.Out Box25.In
+
+connect Box25.Spacing Box19.Spacing
+
+connect Box09.Out Box27.In
+
+connect Box27.Out Box16.In
+
+connect Box20.Out Box28.In0
+
+connect Box21.Out Box28.In1
+
+connect Box22.Out Box28.In2
+
+connect Box28.Out0 Box19.lstPointX
+
+connect Box28.Out1 Box19.lstPointY
+
+connect Box28.Out2 Box19.lstPointZ
+
+connect Box03.Out Box30.In
+
+connect Box30.Out Box05.In
+
+connect Box05.Out Box12.In
+
+connect Box31.Out Box12.Lower
+
+connect Box31.Widget Box11.Widget1
+
+connect Box31.BoxChange Box32.In1
+
+connect Box17.BoxChange Box32.In2
+
+connect Box32.BoxChange Box14.BoxExecute
+
+connect Box18.OutLstX Box33.InLstX
+
+connect Box18.OutLstY Box33.InLstY
+
+connect Box18.OutLstZ Box33.InLstZ
+
+connect Box05.Out Box33.In
+
+connect Box33.OutLstX Box20.In1
+
+connect Box33.OutLstY Box21.In1
+
+connect Box33.OutLstZ Box22.In1
+
+
+
+# Complex input ports
+exec Box06
+exec Box07
BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BestPoint)
BBTK_BLACK_BOX_IMPLEMENTATION(BestPoint,bbtk::AtomicBlackBox);
-//=====
-// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
-//=====
-void BestPoint::Process()
+
+void BestPoint::ProcessPoint(int x,int y, int z, std::vector<int> *pOutPoint , double *pOutputValue)
{
+ *pOutputValue = -999;
+ pOutPoint->push_back(-999);
+ pOutPoint->push_back(-999);
+ pOutPoint->push_back(-999);
+
+ bool ok;
+ int i,j,k;
+ int size;
+ int dimX;
+ int dimY;
+ int dimZ;
+ double value;
+ double dx,dy,dz;
+ double M1,M2,D2,G;
+ double FG,FGback;
+ int minX,minY,minZ;
+ int maxX,maxY,maxZ;
+ int ext[6];
+ G = 1;
+ M1 = 1;
+ bbGetInputIn()->GetExtent(ext);
+ dimX = ext[1]-ext[0]+1;
+ dimY = ext[3]-ext[2]+1;
+ dimZ = ext[5]-ext[4]+1;
+
+ if (bbGetInputType()==1) { *pOutputValue = -9999999; } // finding max
+ if (bbGetInputType()==2) { *pOutputValue = 9999999; } // finding min
+ if (bbGetInputType()==3) { FGback = -9999999; } // finding FG max
+ if (bbGetInputType()==4) { FGback = 9999999; } // finding FG min
- // THE MAIN PROCESSING METHOD BODY
- // Here we simply set the input 'In' value to the output 'Out'
- // And print out the output value
- // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
- // void bbSet{Input|Output}NAME(const TYPE&)
- // const TYPE& bbGet{Input|Output}NAME() const
- // Where :
- // * NAME is the name of the input/output
- // (the one provided in the attribute 'name' of the tag 'input')
- // * TYPE is the C++ type of the input/output
- // (the one provided in the attribute 'type' of the tag 'input')
-// bbSetOutputOut( bbGetInputIn() );
-// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
-
- double outputValue = -999;
- std::vector<int> outPoint;
- outPoint.push_back(-999);
- outPoint.push_back(-999);
- outPoint.push_back(-999);
+ minX = x - bbGetInputBoxSize();
+ minY = y - bbGetInputBoxSize();
+ minZ = z - bbGetInputBoxSize();
+ maxX = x + bbGetInputBoxSize();
+ maxY = y + bbGetInputBoxSize();
+ maxZ = z + bbGetInputBoxSize();
- if ( (bbGetInputIn()!=NULL) && (bbGetInputInPoint().size()==3) )
- {
- bool ok;
- int i,j,k;
- int size;
- int dimX;
- int dimY;
- int dimZ;
- double value;
- double dx,dy,dz;
- int x,y,z;
- double M1,M2,D2,G;
- double FG,FGback;
- int minX,minY,minZ;
- int maxX,maxY,maxZ;
- int ext[6];
- G = 1;
- M1 = 1;
- bbGetInputIn()->GetExtent(ext);
- dimX=ext[1]-ext[0]+1;
- dimY=ext[3]-ext[2]+1;
- dimZ=ext[5]-ext[4]+1;
-
- x = bbGetInputInPoint()[0];
- y = bbGetInputInPoint()[1];
- z = bbGetInputInPoint()[2];
-
- if (bbGetInputType()==1) { outputValue = -9999999; } // finding max
- if (bbGetInputType()==2) { outputValue = 9999999; } // finding min
- if (bbGetInputType()==3) { FGback = -9999999; } // finding FG max
- if (bbGetInputType()==4) { FGback = 9999999; } // finding FG min
-
- minX = x - bbGetInputBoxSize();
- minY = y - bbGetInputBoxSize();
- minZ = z - bbGetInputBoxSize();
- maxX = x + bbGetInputBoxSize();
- maxY = y + bbGetInputBoxSize();
- maxZ = z + bbGetInputBoxSize();
-
- if (minX<0) { minX = 0; }
- if (minY<0) { minY = 0; }
- if (minZ<0) { minZ = 0; }
- if (maxX>=dimX) { maxX = dimX-1; }
- if (maxY>=dimY) { maxY = dimY-1; }
- if (maxZ>=dimZ) { maxZ = dimZ-1; }
+ if (minX<0) { minX = 0; }
+ if (minY<0) { minY = 0; }
+ if (minZ<0) { minZ = 0; }
+ if (maxX>=dimX) { maxX = dimX-1; }
+ if (maxY>=dimY) { maxY = dimY-1; }
+ if (maxZ>=dimZ) { maxZ = dimZ-1; }
- for (i=minX;i<maxX;i++)
+ for (i=minX;i<=maxX;i++)
+ {
+ for (j=minY;j<=maxY;j++)
{
- for (j=minY;j<maxY;j++)
+ for (k=minZ;k<=maxZ;k++)
{
- for (k=minZ;k<maxZ;k++)
+ ok = false;
+ value=bbGetInputIn()->GetScalarComponentAsDouble(i,j,k,0);
+ if (bbGetInputType()==1) // max
{
- ok = false;
- value=bbGetInputIn()->GetScalarComponentAsDouble(i,j,k,0);
- if (bbGetInputType()==1) // max
+ if ( value > *pOutputValue)
{
- if ( value > outputValue)
- {
- ok=true;
- } // if max
- } // if Type == 1
- if (bbGetInputType()==2) // min
- {
- if ( value < outputValue)
- {
- ok=true;
- } // if max
- } // if Type == 2
- if ((bbGetInputType()==3) || (bbGetInputType()==4) ) // FG
+ ok=true;
+ } // if max
+ } // if Type == 1
+ if (bbGetInputType()==2) // min
+ {
+ if ( value < *pOutputValue)
{
- M2 = value;
- dx = x - i;
- dy = y - j;
- dz = z - k;
- D2 = dx*dx + dy*dy + dz*dz;
- if (D2==0) {D2=0.000000001;}
- FG = G * M1 * M2 / D2;
- } // if Type == 3 or 4
- if (bbGetInputType()==3) // max
+ ok=true;
+ } // if max
+ } // if Type == 2
+ if ((bbGetInputType()==3) || (bbGetInputType()==4) ) // FG
+ {
+ M2 = value;
+ dx = x - i;
+ dy = y - j;
+ dz = z - k;
+ D2 = dx*dx + dy*dy + dz*dz;
+ if (D2==0) {D2=0.000000001;}
+ FG = G * M1 * M2 / D2;
+ } // if Type == 3 or 4
+ if (bbGetInputType()==3) // max
+ {
+ if ( FG > FGback)
{
- if ( FG > FGback)
- {
- ok = true;
- FGback = FG;
- } // if max
- } // if Type == 3
- if (bbGetInputType()==4) // min
+ ok = true;
+ FGback = FG;
+ } // if max
+ } // if Type == 3
+ if (bbGetInputType()==4) // min
+ {
+ if ( FG < FGback)
{
- if ( FG < FGback)
- {
- ok = true;
- FGback = FG;
- } // if max
- } // if Type == 4
+ ok = true;
+ FGback = FG;
+ } // if max
+ } // if Type == 4
- if ( ok==true)
- {
- outputValue = value;
- outPoint[0] = i;
- outPoint[1] = j;
- outPoint[2] = k;
- printf("EED BestPoint::Process %d %d %d - %d %d %d \n",x,y,z,i,j,k);
- } // if ok
+ if ( ok==true)
+ {
+ *pOutputValue = value;
+ (*pOutPoint)[0] = i;
+ (*pOutPoint)[1] = j;
+ (*pOutPoint)[2] = k;
+ printf("EED BestPoint::Process %d %d %d - %d %d %d \n",x,y,z,i,j,k);
+ } // if ok
+
+ }// for k
+ }// for j
+ }// for i
+
+}
-
- }// for k
- }// for j
- }// for i
- } // if In != NULL && InPoint.size ==3
+void BestPoint::ProcessListPoints()
+{
+ double outputValue;
+ std::vector<int> outPoint;
+ int x,y,z;
+ std::vector<int> LstX=bbGetInputInLstX();
+ std::vector<int> LstY=bbGetInputInLstY();
+ std::vector<int> LstZ=bbGetInputInLstZ();
+ int i,size = LstX.size();
+ std::vector<int> OutLstX;
+ std::vector<int> OutLstY;
+ std::vector<int> OutLstZ;
+ std::vector<double> OutLstValues;
+ if ( (LstY.size()==size) && (LstZ.size()==size) )
+ {
+ for ( i=0 ; i<size ; i++ )
+ {
+ x = LstX[i];
+ y = LstY[i];
+ z = LstZ[i];
+ outPoint.clear();
+ ProcessPoint( x,y,z, &outPoint,&outputValue );
+ OutLstX.push_back( outPoint[0] );
+ OutLstY.push_back( outPoint[1] );
+ OutLstZ.push_back( outPoint[2] );
+ OutLstValues.push_back( outputValue );
+ } // for i
+ } // if list size X Y Z
+ bbSetOutputOutLstX(OutLstX);
+ bbSetOutputOutLstY(OutLstY);
+ bbSetOutputOutLstZ(OutLstZ);
+ bbSetOutputOutLstValues(OutLstValues);
+}
- bbSetOutputOut(outPoint);
- bbSetOutputValue(outputValue);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void BestPoint::Process()
+{
+
+ if (bbGetInputIn()==NULL)
+ {
+ printf("EED BestPoint::Process Warning!!!!! mising input image (In) \n");
+ }
+
+ double outputValue;
+ std::vector<int> outPoint;
+ if ( (bbGetInputIn()!=NULL) && (bbGetInputInPoint().size()==3) )
+ {
+ ProcessPoint( bbGetInputInPoint()[0] , bbGetInputInPoint()[1] , bbGetInputInPoint()[2], &outPoint,&outputValue );
+ bbSetOutputOut(outPoint);
+ bbSetOutputValue(outputValue);
+ }
+ if ( (bbGetInputIn()!=NULL) && (bbGetInputInLstX().size()>0) )
+ {
+ ProcessListPoints();
+ }
}
//=====
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
bbSetInputIn(NULL);
+ bbSetInputBoxSize(3);
}
//=====
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
- BBTK_DECLARE_INPUT(In,vtkImageData*);
- BBTK_DECLARE_INPUT(Type,int);
- BBTK_DECLARE_INPUT(BoxSize,int);
- BBTK_DECLARE_INPUT(InPoint,std::vector<int>);
- BBTK_DECLARE_OUTPUT(Out,std::vector<int>);
- BBTK_DECLARE_OUTPUT(Value,double);
- BBTK_PROCESS(Process);
+ BBTK_DECLARE_INPUT(In,vtkImageData*);
+ BBTK_DECLARE_INPUT(Type,int);
+ BBTK_DECLARE_INPUT(BoxSize,int);
+ BBTK_DECLARE_INPUT(InPoint,std::vector<int>);
+ BBTK_DECLARE_INPUT(InLstX,std::vector<int>);
+ BBTK_DECLARE_INPUT(InLstY,std::vector<int>);
+ BBTK_DECLARE_INPUT(InLstZ,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(Out,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(Value,double);
+ BBTK_DECLARE_OUTPUT(OutLstX,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(OutLstY,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(OutLstZ,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(OutLstValues,std::vector<double>);
+ BBTK_PROCESS(Process);
void Process();
-//=====
+ void ProcessPoint(int x,int y, int z, std::vector<int>* pOutPoint , double *pOutValue);
+ void ProcessListPoints();
+//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
};
BBTK_CATEGORY("empty");
BBTK_INPUT(BestPoint,In,"Input image",vtkImageData*,"");
BBTK_INPUT(BestPoint,Type,"0:nothing, 1:point max value, 2:point mininum value 3:Gravitational max point, 4:Gravitational min point",int,"");
- BBTK_INPUT(BestPoint,BoxSize,"Box size to searche the best point (impar number)",int,"");
+ BBTK_INPUT(BestPoint,BoxSize,"(default 3) Impar number. Box size to searche the best point",int,"");
BBTK_INPUT(BestPoint,InPoint,"Input point",std::vector<int>,"");
+ BBTK_INPUT(BestPoint,InLstX,"List X",std::vector<int>,"");
+ BBTK_INPUT(BestPoint,InLstY,"List Y",std::vector<int>,"");
+ BBTK_INPUT(BestPoint,InLstZ,"List Z",std::vector<int>,"");
BBTK_OUTPUT(BestPoint,Out,"Output point",std::vector<int>,"");
BBTK_OUTPUT(BestPoint,Value,"Output value",double,"");
+ BBTK_OUTPUT(BestPoint,OutLstX,"Output list X",std::vector<int>,"");
+ BBTK_OUTPUT(BestPoint,OutLstY,"Output list Y",std::vector<int>,"");
+ BBTK_OUTPUT(BestPoint,OutLstZ,"Output list Z",std::vector<int>,"");
+ BBTK_OUTPUT(BestPoint,OutLstValues,"Lst of values",std::vector<double>,"");
BBTK_END_DESCRIBE_BLACK_BOX(BestPoint);
//=====
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbcreaVtkBifurcationsInSkeletonization.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BifurcationsInSkeletonization)
+BBTK_BLACK_BOX_IMPLEMENTATION(BifurcationsInSkeletonization,bbtk::AtomicBlackBox);
+
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void BifurcationsInSkeletonization::Process()
+{
+ printf("EED BifurcationsInSkeletonization::Process start \n");
+ std::vector<int> tmpLstX=bbGetInputLstX();
+ std::vector<int> tmpLstY=bbGetInputLstY();
+ std::vector<int> tmpLstZ=bbGetInputLstZ();
+ std::vector<int> leavesLstX;
+ std::vector<int> leavesLstY;
+ std::vector<int> leavesLstZ;
+ std::vector<int> outLstX;
+ std::vector<int> outLstY;
+ std::vector<int> outLstZ;
+
+ if (bbGetInputIn()!=NULL)
+ {
+ int dim[3];
+ int ext[6];
+ bbGetInputIn()->GetExtent(ext);
+ dim[0] = ext[1]-ext[0]+1;
+ dim[1] = ext[3]-ext[2]+1;
+ dim[2] = ext[5]-ext[4]+1;
+ vtkImageData *tmpImage = vtkImageData::New();
+ tmpImage->DeepCopy( bbGetInputIn() );
+ int px,py,pz, i,j,k, tx,ty,tz, ii,size;
+ // Find all leaves
+ long int w=1;
+ int ww;
+ bool ok;
+ while (tmpLstX.size()!=0)
+ {
+ px = tmpLstX[0];
+ py = tmpLstY[0];
+ pz = tmpLstZ[0];
+ tmpLstX.erase( tmpLstX.begin() );
+ tmpLstY.erase( tmpLstY.begin() );
+ tmpLstZ.erase( tmpLstZ.begin() );
+ w = w + 1;
+ tmpImage->SetScalarComponentFromDouble( px,py,pz,0,w);
+ ok=false;
+ for ( i=px-1 ; i<=px+1 ; i++)
+ {
+ for ( j=py-1 ; j<=py+1;j++)
+ {
+ for ( k=pz-1 ; k<=pz+1 ; k++ )
+ {
+ if (!((px==i) && (py==j) && (pz==k)))
+ {
+ if ((i>=0) &&(j>=0) &&(k>=0) &&(i<dim[0]) &&(j<dim[1]) &&(k<dim[2]) )
+ {
+ if (1==tmpImage->GetScalarComponentAsDouble(i,j,k,0))
+ {
+ ok=true;
+ tmpLstX.push_back(i);
+ tmpLstY.push_back(j);
+ tmpLstZ.push_back(k);
+ } // if graylevel == 1
+ } // if ijk>0 && ijk<dim
+ } // if px,py,pz != i,j,k
+ } // for k
+ } // for j
+ } // for i
+ if (ok==false)
+ {
+ leavesLstX.push_back(px);
+ leavesLstY.push_back(py);
+ leavesLstZ.push_back(pz);
+ } //
+ } // while tmpLstX.size()!=0
+
+ size = leavesLstX.size();
+ // Cleaning repeated leaves
+ for (i=size-1; i>=0; i--)
+ {
+ for (ii=size-1; ii>i; ii--)
+ {
+ if ( (leavesLstX[i]==leavesLstX[ii]) && (leavesLstY[i]==leavesLstY[ii]) && (leavesLstZ[i]==leavesLstZ[ii]) )
+ {
+ leavesLstX.erase( leavesLstX.begin()+ii );
+ leavesLstY.erase( leavesLstY.begin()+ii );
+ leavesLstZ.erase( leavesLstZ.begin()+ii );
+ size--;
+ } // if iPoint == iiPoint
+ }// for ii
+ } // for i
+
+ ww=-1;
+ double gl;
+ // Find all bifurcations
+ while (leavesLstX.size()!=0)
+ {
+ px = leavesLstX[0];
+ py = leavesLstY[0];
+ pz = leavesLstZ[0];
+ leavesLstX.erase( leavesLstX.begin() );
+ leavesLstY.erase( leavesLstY.begin() );
+ leavesLstZ.erase( leavesLstZ.begin() );
+ w = tmpImage->GetScalarComponentAsDouble(px,py,pz,0);
+// printf("EED BifurcationsInSkeletonization::Process px,py,pz %d %d %d w=%ld ww=%d \n", px,py,pz, w,ww);
+ ok = true;
+ while ( (tmpImage->GetScalarComponentAsDouble(px,py,pz,0)!=1) && (ok==true) )
+ {
+ // w = w - 1;
+ w = tmpImage->GetScalarComponentAsDouble(px,py,pz,0);
+ ok = false;
+ tmpImage->SetScalarComponentFromDouble( px,py,pz,0,ww);
+ for ( i=px-1 ; i<=px+1 ; i++ )
+ {
+ for ( j=py-1 ; j<=py+1 ; j++ )
+ {
+ for ( k=pz-1 ; k<=pz+1 ; k++ )
+ {
+ if (!((px==i) && (py==j) && (pz==k)))
+ {
+ gl = tmpImage->GetScalarComponentAsDouble(i,j,k,0);
+ if ((gl<w) && (gl>0) )
+ {
+ tx = i;
+ ty = j;
+ tz = k;
+ ok = true;
+// printf("EED BifurcationsInSkeletonization::Process tx,ty,tz %d %d %d \n", tx,ty,tz);
+ } // if graylevel == w
+ } // if px,py,pz != i,j,k
+ } // for k
+ } // for j
+ } // for i
+ px = tx;
+ py = ty;
+ pz = tz;
+ } // while graylevel!=1 && ok==true
+
+ ww = ww -1;
+ outLstX.push_back( px );
+ outLstY.push_back( py );
+ outLstZ.push_back( pz );
+ } // while leavesLstX.size()!=0
+
+ bbSetOutputOutLstX(outLstX);
+ bbSetOutputOutLstY(outLstY);
+ bbSetOutputOutLstZ(outLstZ);
+ bbSetOutputOut(tmpImage);
+ } else {
+ bbSetOutputOutLstX(outLstX);
+ bbSetOutputOutLstY(outLstY);
+ bbSetOutputOutLstZ(outLstZ);
+ bbSetOutputOut(NULL);
+ }
+ printf("EED BifurcationsInSkeletonization::Process end\n");
+}
+
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void BifurcationsInSkeletonization::bbUserSetDefaultValues()
+{
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputIn(NULL);
+}
+
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void BifurcationsInSkeletonization::bbUserInitializeProcessing()
+{
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+}
+
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void BifurcationsInSkeletonization::bbUserFinalizeProcessing()
+{
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+}
+
+} // EO namespace bbcreaVtk
+
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#ifndef __bbcreaVtkBifurcationsInSkeletonization_h_INCLUDED__
+#define __bbcreaVtkBifurcationsInSkeletonization_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkImageData.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT BifurcationsInSkeletonization
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(BifurcationsInSkeletonization,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+ BBTK_DECLARE_INPUT(In,vtkImageData*);
+ BBTK_DECLARE_INPUT(LstX,std::vector<int>);
+ BBTK_DECLARE_INPUT(LstY,std::vector<int>);
+ BBTK_DECLARE_INPUT(LstZ,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(OutLstX,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(OutLstY,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(OutLstZ,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+ BBTK_PROCESS(Process);
+ void Process();
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(BifurcationsInSkeletonization,bbtk::AtomicBlackBox);
+ BBTK_NAME("BifurcationsInSkeletonization");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("empty");
+ BBTK_INPUT(BifurcationsInSkeletonization,In,"Input image (Ex: Skeleton from ThinningImageFilter3D filter)",vtkImageData*,"");
+ BBTK_INPUT(BifurcationsInSkeletonization,LstX,"Start points in X" ,std::vector<int>,"");
+ BBTK_INPUT(BifurcationsInSkeletonization,LstY,"Start points in Y" ,std::vector<int>,"");
+ BBTK_INPUT(BifurcationsInSkeletonization,LstZ,"Start points in Z" ,std::vector<int>,"");
+ BBTK_OUTPUT(BifurcationsInSkeletonization,OutLstX,"List X bifurcations" ,std::vector<int>,"");
+ BBTK_OUTPUT(BifurcationsInSkeletonization,OutLstY,"List Y bifurcations" ,std::vector<int>,"");
+ BBTK_OUTPUT(BifurcationsInSkeletonization,OutLstZ,"List Z bifurcations" ,std::vector<int>,"");
+ BBTK_OUTPUT(BifurcationsInSkeletonization,Out,"Out image",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(BifurcationsInSkeletonization);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+
+}// EO namespace bbcreaVtk
+#endif // __bbcreaVtkBifurcationsInSkeletonization_h_INCLUDED__
+