2 // 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)
4 #include "bbcreaVtkImageThresholdConnectivity.h"
5 #include "bbcreaVtkPackage.h"
6 #include "vtkImageThresholdConnectivity.h"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageThresholdConnectivity)
13 BBTK_BLACK_BOX_IMPLEMENTATION(ImageThresholdConnectivity,bbtk::AtomicBlackBox);
15 // 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)
17 void ImageThresholdConnectivity::Process()
19 // THE MAIN PROCESSING METHOD BODY
20 // Here we simply set the input 'In' value to the output 'Out'
21 // And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 // void bbSet{Input|Output}NAME(const TYPE&)
24 // const TYPE& bbGet{Input|Output}NAME() const
26 // * NAME is the name of the input/output
27 // (the one provided in the attribute 'name' of the tag 'input')
28 // * TYPE is the C++ type of the input/output
29 // (the one provided in the attribute 'type' of the tag 'input')
31 std::vector<int> lstX;
32 std::vector<int> lstY;
33 std::vector<int> lstZ;
34 std::vector<int> point = bbGetInputPoint();
36 if (bbGetInputPoint().size()==3)
38 lstX.push_back( point[0] );
39 lstY.push_back( point[1] );
40 lstZ.push_back( point[2] );
42 lstX = bbGetInputLstX();
43 lstY = bbGetInputLstY();
44 lstZ = bbGetInputLstZ();
47 if ( (bbGetInputIn()!=NULL) && (lstX.size()>0) && (lstX.size()==lstY.size()) && (lstX.size()==lstZ.size()) )
49 vtkImageThresholdConnectivity *filter = vtkImageThresholdConnectivity::New();
51 bbGetInputIn()->GetSpacing(spc);
52 int border = bbGetInputBorder();
59 int i,size = lstX.size();
61 vtkPoints *points = vtkPoints::New();
62 for (i=0; i<size; i++)
64 p[0] = lstX[i]*spc[0];
65 p[1] = lstY[i]*spc[1];
66 p[2] = lstZ[i]*spc[2];
67 points->InsertNextPoint(p);
68 if ( lstX[i] < minX ) { minX = lstX[i]; }
69 if ( lstY[i] < minY ) { minY = lstY[i]; }
70 if ( lstZ[i] < minZ ) { minZ = lstZ[i]; }
71 if ( lstX[i] > maxX ) { maxX = lstX[i]; }
72 if ( lstY[i] > maxY ) { maxY = lstY[i]; }
73 if ( lstZ[i] > maxZ ) { maxZ = lstZ[i]; }
75 filter->SetSeedPoints( points );
76 filter->SetInputData( bbGetInputIn() );
77 if (bbGetInputThreshold().size()==2)
79 filter->ThresholdBetween( bbGetInputThreshold()[0] , bbGetInputThreshold()[1] );
81 filter->ThresholdBetween( 0, 100 );
84 // filter->SetNeighborhoodRadius (4, 4, 4 );
85 filter->SetInValue(255);
86 filter->SetOutValue(0);
87 // filter->ReplaceInOn();
88 // filter->ReplaceOutOn();
89 filter->SetSliceRangeX(minX-border,maxX+border);
90 filter->SetSliceRangeY(minY-border,maxY+border);
91 filter->SetSliceRangeZ(minZ-border,maxZ+border);
93 bbSetOutputOut( filter->GetOutput() );
95 bbSetOutputOut( NULL );
99 // 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)
101 void ImageThresholdConnectivity::bbUserSetDefaultValues()
103 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
104 // Here we initialize the input 'In' to 0
106 bbSetInputBorder(10);
107 std::vector<double> maskValue;
108 maskValue.push_back(0);
109 maskValue.push_back(255);
110 bbSetInputMaskValue(maskValue);
115 // 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)
117 void ImageThresholdConnectivity::bbUserInitializeProcessing()
119 // THE INITIALIZATION METHOD BODY :
121 // but this is where you should allocate the internal/output pointers
126 // 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)
128 void ImageThresholdConnectivity::bbUserFinalizeProcessing()
130 // THE FINALIZATION METHOD BODY :
132 // but this is where you should desallocate the internal/output pointers
136 }// EO namespace bbcreaVtk