X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkImageThresholdConnectivity.cxx;h=a368cc5cc94f1f99f78329f7684b4ad52b104377;hb=500bc2ff1c3fe51a9ce94324dee722fb2f7bfd36;hp=71366434d86e5184c05c28be6b201ca48bbb589d;hpb=8b897e95b16fec9d4da9e687b750101f6f16e173;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx index 7136643..a368cc5 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThresholdConnectivity.cxx @@ -3,6 +3,9 @@ //===== #include "bbcreaVtkImageThresholdConnectivity.h" #include "bbcreaVtkPackage.h" +#include "vtkImageThresholdConnectivity.h" +#include "vtkPoints.h" + namespace bbcreaVtk { @@ -13,7 +16,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ImageThresholdConnectivity,bbtk::AtomicBlackBox); //===== void ImageThresholdConnectivity::Process() { - // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value @@ -26,49 +28,117 @@ void ImageThresholdConnectivity::Process() // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') - - printf("EED ImageThresholdConnectivity::Process Error this box is not implemented .... \n"); - printf("EED ImageThresholdConnectivity::Process Error this box is not implemented .... \n"); - printf("EED ImageThresholdConnectivity::Process Error this box is not implemented .... \n"); - printf("EED ImageThresholdConnectivity::Process Error this box is not implemented .... \n"); + std::vector lstX; + std::vector lstY; + std::vector lstZ; + std::vector point = bbGetInputPoint(); + + if (bbGetInputPoint().size()==3) + { + lstX.push_back( point[0] ); + lstY.push_back( point[1] ); + lstZ.push_back( point[2] ); + } else { + lstX = bbGetInputLstX(); + lstY = bbGetInputLstY(); + lstZ = bbGetInputLstZ(); + } + + if ( (bbGetInputIn()!=NULL) && (lstX.size()>0) && (lstX.size()==lstY.size()) && (lstX.size()==lstZ.size()) ) + { + if (filter!=NULL) { filter->Delete(); } + filter = vtkImageThresholdConnectivity::New(); + double spc[3]; + bbGetInputIn()->GetSpacing(spc); + int border = bbGetInputBorder(); + int minX = 32000; + int minY = 32000; + int minZ = 32000; + int maxX = -32000; + int maxY = -32000; + int maxZ = -32000; + int i,size = lstX.size(); + double p[3]; + vtkPoints *points = vtkPoints::New(); + for (i=0; iInsertNextPoint(p); + if ( lstX[i] < minX ) { minX = lstX[i]; } + if ( lstY[i] < minY ) { minY = lstY[i]; } + if ( lstZ[i] < minZ ) { minZ = lstZ[i]; } + if ( lstX[i] > maxX ) { maxX = lstX[i]; } + if ( lstY[i] > maxY ) { maxY = lstY[i]; } + if ( lstZ[i] > maxZ ) { maxZ = lstZ[i]; } + } // for i + filter->SetSeedPoints( points ); + filter->SetInputData( bbGetInputIn() ); + if (bbGetInputThreshold().size()==2) + { + if ( bbGetInputThreshold()[0] < bbGetInputThreshold()[1] ) + { + filter->ThresholdBetween( bbGetInputThreshold()[0] , bbGetInputThreshold()[1] ); + } else { + filter->ThresholdBetween( bbGetInputThreshold()[1] , bbGetInputThreshold()[0] ); + }// if Thershold min max + } else { + filter->ThresholdBetween( 0, 100 ); + }// if Thershold size + + // filter->SetNeighborhoodRadius (4, 4, 4 ); + filter->SetInValue(255); + filter->SetOutValue(0); + // filter->ReplaceInOn(); + // filter->ReplaceOutOn(); + filter->SetSliceRangeX(minX-border,maxX+border); + filter->SetSliceRangeY(minY-border,maxY+border); + filter->SetSliceRangeZ(minZ-border,maxZ+border); + filter->Update(); + bbSetOutputOut( filter->GetOutput() ); + } else { + bbSetOutputOut( NULL ); + }// if lst } //===== // 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 ImageThresholdConnectivity::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - bbSetInputIn(NULL); - + filter=NULL; + bbSetInputIn(NULL); + bbSetInputBorder(10); + std::vector maskValue; + maskValue.push_back(0); + maskValue.push_back(255); + bbSetInputMaskValue(maskValue); } + //===== // 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 ImageThresholdConnectivity::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - +// 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 ImageThresholdConnectivity::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - -} } -// EO namespace bbcreaVtk + +}// EO namespace bbcreaVtk