]> Creatis software - bbtk.git/commitdiff
#2981 BBTK Feature New Normal - FormatOutput of filters in string
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 30 Jun 2016 00:47:38 +0000 (02:47 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 30 Jun 2016 00:47:38 +0000 (02:47 +0200)
packages/vtk/src/bbtkSimpleUtilities.h
packages/vtk/src/bbtkStaticLecture.cxx
packages/vtk/src/bbtkStaticLecture.h
packages/vtk/src/bbvtkRescaleSlopeIntercept.cxx
packages/vtk/src/bbvtkRescaleSlopeIntercept.h
packages/vtk/src/bbvtkSegmentationConnectivity.cxx
packages/vtk/src/bbvtkSegmentationConnectivity.h

index 874c35c1b351500470877bd5b47a3be0ebf0e36c..067af425a2743d138bdd84c447aa921d08c5b9b9 100755 (executable)
@@ -366,4 +366,4 @@ class sorts
 
 }
 
-#endif /* _DLL_H_ */
+#endif // _BBTKSIMPLEUTILITIES_H_
index e166919ed9f2b09e368ab4ca7ce63cddc105a2f3..fc1f9af7dd468b35ef8e0356f093ade9510f5bb3 100755 (executable)
 
 #include "bbtkStaticLecture.h"
 
+#include <string>
+
+int bbtkStaticLecture::GetTypeFormat( std::string formatStr , vtkImageData* image )
+{
+       int outputformat = VTK_UNSIGNED_CHAR;
+       if (formatStr=="SAME")
+       {                                               
+               if (image!=NULL) outputformat = image->GetScalarType();
+       }
+       else if (formatStr=="VTK_BIT")                          outputformat = VTK_BIT;                         // 1
+       else if (formatStr=="VTK_CHAR")                         outputformat = VTK_CHAR;                        // 2
+       else if (formatStr=="VTK_SIGNED_CHAR")          outputformat = VTK_SIGNED_CHAR;         // 15
+       else if (formatStr=="VTK_UNSIGNED_CHAR")        outputformat = VTK_UNSIGNED_CHAR;       // 3
+       else if (formatStr=="VTK_SHORT")                        outputformat = VTK_SHORT;                       // 4
+       else if (formatStr=="VTK_UNSIGNED_SHORT")       outputformat = VTK_UNSIGNED_SHORT;      // 5
+       else if (formatStr=="VTK_INT")                          outputformat = VTK_INT;                 // 6
+       else if (formatStr=="VTK_UNSIGNED_INT")         outputformat = VTK_UNSIGNED_INT;        // 7
+       else if (formatStr=="VTK_LONG")                         outputformat = VTK_LONG;                // 8  
+       else if (formatStr=="VTK_UNSIGNED_LONG")        outputformat = VTK_UNSIGNED_LONG;       // 9
+       else if (formatStr=="VTK_FLOAT")                        outputformat = VTK_FLOAT;               // 10
+       else if (formatStr=="VTK_DOUBLE")                       outputformat = VTK_DOUBLE;              // 11 
+       else if (formatStr=="MET_CHAR")                         outputformat = VTK_CHAR;                        // 2
+       else if (formatStr=="MET_UCHAR")                        outputformat = VTK_UNSIGNED_CHAR;       // 3
+       else if (formatStr=="MET_SHORT")                        outputformat = VTK_SHORT;                       // 4
+       else if (formatStr=="MET_USHORT")                       outputformat = VTK_UNSIGNED_SHORT;      // 5
+       else if (formatStr=="MET_SHORT")                        outputformat = VTK_SHORT;               // 4
+       else if (formatStr=="MET_FLOAT")                        outputformat = VTK_FLOAT;               // 10
+       else if (formatStr=="MET_DOUBLE")                       outputformat = VTK_DOUBLE;              // 11  
+
+    return outputformat;
+}
+
+
 
        void bbtkStaticLecture::setPixelValue(int i, int j, int k, vtkImageData* img, double value)
        {
index 9b214e773767df97a1cfa6e7c6b67599d8b86c5a..35b0624ce39624478f11917ca43b8d703eee4bd9 100755 (executable)
@@ -34,8 +34,9 @@
 class bbtkStaticLecture
 {
 public:
-       void setPixelValue(int i, int j, int k, vtkImageData* img, double value);
-       double getPixelValue(int i, int j, int k, vtkImageData* img);
+       static int      GetTypeFormat( std::string formatStr , vtkImageData* image );
+       void    setPixelValue(int i, int j, int k, vtkImageData* img, double value);
+       double  getPixelValue(int i, int j, int k, vtkImageData* img);
 };
 
 #endif
index dc4e0afc299a4effc6e758f5149a2087a4f67482..117b97931a3c68e7634a99f9cb074b2d4e5ceb6b 100644 (file)
@@ -31,6 +31,7 @@
 #include "bbvtkRescaleSlopeIntercept.h"
 #include "bbvtkPackage.h"
 
+#include "bbtkStaticLecture.h"
 
 namespace bbvtk
 {
@@ -65,19 +66,9 @@ void RescaleSlopeIntercept::Process()
        
        if (bbGetInputIn()!=0)
        {
-               if (bbGetInputOutputFormat()=="SAME")                                   outputformat = bbGetInputIn()->GetScalarType();
-               else if (bbGetInputOutputFormat()=="VTK_BIT")                   outputformat = VTK_BIT;            // 1
-               else if (bbGetInputOutputFormat()=="VTK_CHAR")                  outputformat = VTK_CHAR;           // 2
-               else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR")           outputformat = VTK_SIGNED_CHAR;    // 15
-               else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR")         outputformat = VTK_UNSIGNED_CHAR;  // 3
-               else if (bbGetInputOutputFormat()=="VTK_SHORT")                 outputformat = VTK_SHORT;          // 4
-               else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT")        outputformat = VTK_UNSIGNED_SHORT; // 5
-               else if (bbGetInputOutputFormat()=="VTK_INT")                   outputformat = VTK_INT;            // 6
-               else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT")          outputformat = VTK_UNSIGNED_INT;   // 7
-               else if (bbGetInputOutputFormat()=="VTK_LONG")                  outputformat = VTK_LONG;           // 8  
-               else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG")         outputformat = VTK_UNSIGNED_LONG;  // 9
-               else if (bbGetInputOutputFormat()=="VTK_FLOAT")                 outputformat = VTK_FLOAT;          // 10
-               else if (bbGetInputOutputFormat()=="VTK_DOUBLE")                outputformat = VTK_DOUBLE;         // 11 
+
+
+               int outputformat = bbtkStaticLecture::GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() );
                
                
                bbGetInputIn()->GetScalarRange(range);
index 77ef177c41e03ed62157579604307d49bb053580..10d67b9db4a2146b9d5557a92a80caeeffe91ac0 100644 (file)
@@ -59,8 +59,7 @@ class bbvtk_EXPORT RescaleSlopeIntercept
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
   BBTK_PROCESS(Process);
   void Process();
-       
-       int                                                     outputformat;
+
        vtkImageShiftScale                      *filter1;
        vtkImageShiftScale                      *filter2;
        vtkImageChangeInformation       *mchange;
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();                      
index 57399afe3c7a10becf7f968581ee3570e8944aee..bd4b4797159bd120fff6c07d245871da6d904cc5 100644 (file)
@@ -71,6 +71,8 @@ namespace bbvtk
     BBTK_DECLARE_INPUT(In,vtkImageData *);
     BBTK_DECLARE_INPUT(PositionXYZ,std::vector<int>);
     BBTK_DECLARE_INPUT(ThresholdMinMax,std::vector<int>);
+    BBTK_DECLARE_INPUT(Value,unsigned char);
+    BBTK_DECLARE_INPUT( OutputFormat , std::string );
     BBTK_DECLARE_OUTPUT(Out,vtkImageData *);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
@@ -78,7 +80,7 @@ namespace bbvtk
   protected:
 
   private:
-       vtkImageCast             *cast2;
+//     vtkImageCast             *cast2;
        vtkImageCast             *cast4; // binary segmentation result
        vtkImageThreshold        *thresh2;
        vtkImageSeedConnectivity *connect2;
@@ -86,14 +88,19 @@ namespace bbvtk
   };
 
   BBTK_BEGIN_DESCRIBE_BLACK_BOX(SegmentationConnectivity,bbtk::AtomicBlackBox);
-  BBTK_NAME("SegmentationConnectivity");
-  BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
-  BBTK_DESCRIPTION("Segmentation with min max threshold and connectivity");
-  BBTK_INPUT(SegmentationConnectivity,In,"Input image",vtkImageData *,"");
-  BBTK_INPUT(SegmentationConnectivity,PositionXYZ,"vector with the Position [x y z]" , std::vector<int>,"");
-  BBTK_INPUT(SegmentationConnectivity,ThresholdMinMax,"vector with the Threshold [min max]" , std::vector<int>,"");
-  BBTK_OUTPUT(SegmentationConnectivity,Out,"Result image",vtkImageData *,"");
-  BBTK_END_DESCRIBE_BLACK_BOX(SegmentationConnectivity);
+    BBTK_NAME("SegmentationConnectivity");
+    BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
+    BBTK_DESCRIPTION("Segmentation with min max threshold and connectivity");
+
+    BBTK_INPUT(SegmentationConnectivity,In,"Input image",vtkImageData *,"");
+    BBTK_INPUT(SegmentationConnectivity,PositionXYZ,"vector with the Position [x y z]" , std::vector<int>,"");
+    BBTK_INPUT(SegmentationConnectivity,ThresholdMinMax,"vector with the Threshold [min max]" , std::vector<int>,"");
+    BBTK_INPUT(SegmentationConnectivity,Value,"(255 default) [0..255] Gey level of output image" , unsigned char,"");
+    BBTK_INPUT(SegmentationConnectivity,OutputFormat,"Image output format:  SAME (default), VTK_BIT, VTK_CHAR, VTK_SIGNED_CHAR, VTK_UNSIGNED_CHAR, VTK_SHORT, VTK_UNSIGNED_SHORT, VTK_INT, VTK_UNSIGNED_INT, VTK_LONG, VTK_UNSIGNED_LONG, VTK_FLOAT, VTK_DOUBLE",std::string,"");
+
+    BBTK_OUTPUT(SegmentationConnectivity,Out,"Result image",vtkImageData *,"");
+ BBTK_END_DESCRIBE_BLACK_BOX(SegmentationConnectivity);
 
 } // EO namespace bbvtk