]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkSegmentationConnectivity.cxx
#2981 BBTK Feature New Normal - FormatOutput of filters in string
[bbtk.git] / packages / vtk / src / bbvtkSegmentationConnectivity.cxx
index 679e0706aa5530eb68a30d28860d995f98e7ac86..218c9db239d416b70a09501db280729f65a5106d 100644 (file)
@@ -43,6 +43,8 @@
 #include "bbvtkSegmentationConnectivity.h"
 #include "bbvtkPackage.h"
 
+#include "bbtkStaticLecture.h"
+
 namespace bbvtk
 {
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
@@ -54,7 +56,7 @@ namespace bbvtk
   void SegmentationConnectivity::bbUserSetDefaultValues() 
   { 
          thresh2       = NULL;
-         cast2         = NULL;
+//       cast2         = NULL;
          connect2      = NULL;
          cast4         = NULL;
                
@@ -69,12 +71,32 @@ namespace bbvtk
          threshold.push_back(0);
          bbSetInputThresholdMinMax(threshold);
          bbSetOutputOut(NULL);
+
+         bbSetInputOutputFormat("SAME");
+         bbSetInputValue(255);
+
+
   }
 
 // --------------------------------------------------------------
                
        void SegmentationConnectivity::bbUserInitializeProcessing()
        {
+
+               thresh2 = vtkImageThreshold::New();
+                       thresh2->SetInValue(255);
+                       thresh2->SetOutputScalarTypeToUnsignedChar();
+               connect2 = vtkImageSeedConnectivity::New();
+                       connect2->SetInput(thresh2->GetOutput());
+                       connect2->SetInputConnectValue(255);
+                       connect2->SetOutputConnectedValue( 255 );
+                       connect2->SetOutputUnconnectedValue(0);
+               cast4 = vtkImageCast::New();
+                       cast4->SetInput(connect2->GetOutput());
+
+// EED 2016 06 15
+
+/*
                thresh2 = vtkImageThreshold::New();
                        thresh2->SetInValue(255);
                        thresh2->SetOutputScalarTypeToUnsignedShort();
@@ -90,6 +112,8 @@ namespace bbvtk
                cast4 = vtkImageCast::New();
                        cast4->SetInput(connect2->GetOutput());
                        cast4->SetOutputScalarTypeToUnsignedShort();
+*/
+
        }
 
 // --------------------------------------------------------------
@@ -101,11 +125,11 @@ namespace bbvtk
                  thresh2->Delete();
                  thresh2=NULL;
          }
-         if (cast2!=NULL)
-         {
-                 cast2->Delete();
-                 cast2=NULL;
-         }
+//       if (cast2!=NULL)
+//       {
+//               cast2->Delete();
+//               cast2=NULL;
+//       }
          if (connect2!=NULL)
          {
                  connect2->Delete();
@@ -118,10 +142,17 @@ namespace bbvtk
          }  
   }
 
+
+
+
 // --------------------------------------------------------------
                
   void SegmentationConnectivity::DoProcess()
   {
+       int outputformat = bbtkStaticLecture::GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() );
+
+
+
     vtkImageData *imagedata = bbGetInputIn();
     imagedata->UpdateInformation();
     imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
@@ -131,8 +162,9 @@ namespace bbvtk
     thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
     thresh2->Modified();
     thresh2->Update();
-    cast2->Modified();
-    cast2->Update();
+// EED 2016 06 15
+//    cast2->Modified();
+//    cast2->Update();
     connect2->RemoveAllSeeds ();
          
        int x = bbGetInputPositionXYZ()[0];
@@ -153,6 +185,9 @@ namespace bbvtk
          if ( z>=maxz ) {  printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range z: %d -> %d \n",y, maxz-1 ); z=maxz-1; }
          
          connect2->AddSeed( x,y,z );
+         connect2->SetOutputConnectedValue( bbGetInputValue() );
+         cast4->SetOutputScalarType( outputformat );
+
          connect2->Modified();
          connect2->Update();
          cast4->Update();