]> Creatis software - creaVtk.git/commitdiff
#3497 MultipleOperations box average option in creaVtk
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 20 Dec 2022 14:07:13 +0000 (15:07 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 20 Dec 2022 14:07:13 +0000 (15:07 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.h

index fe7b4fab56963e4c5a56b7a50b268c5500363205..b5b02b8816251afe10fc626e258a8a282513c652 100644 (file)
@@ -47,7 +47,7 @@ void MultipleOperations::Process()
                resultImage->AllocateScalars( bbGetInputInLst()[0]->GetScalarType(),1 );
                long int index,size=dimXImage*dimYImage*dimZImage;
                DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,resultImage )
-               if (bbGetInputType()==20)
+               if ((bbGetInputType()==20) ||  (bbGetInputType()==21) )
                {
 
 long int k1omp=(double)(size-1)*0.0;
@@ -59,24 +59,35 @@ long int k6omp=(double)(size-1)*1.0;
 
 printf("EED MultipleOperations::Process (with openmp)\n");
 #pragma omp parallel for
-                       for (index=0;index<size;index++)
+
+            for (index=0;index<size;index++)
                        {
 if ( (k1omp==index) || (k2omp==index) || (k3omp==index) || 
      (k4omp==index) || (k5omp==index) || (k6omp==index) ) { printf("  %d%\n", (int)(((double)index/(double)(size-1))*100 )); }
 
                                DEF_POINTER_IMAGE_VTK_CREA(vIn ,ssIn ,pIn ,stIn ,bbGetInputInLst()[0] )
-                               int iLst,sizeLst= bbGetInputInLst().size();
-                               double vInBack,acumDiff;
-                               acumDiff=0;
-                               for (iLst=0;iLst<sizeLst;iLst++) // volumes
+                
+                int iLst,sizeLst= bbGetInputInLst().size();
+                double vInBack  ;
+                double acumDiff ;
+                vInBack  = 0;
+                acumDiff = 0;
+                               for ( iLst=0 ; iLst < sizeLst ; iLst++ ) // volumes
                                {
                                        pIn=(char*)( bbGetInputInLst()[iLst]->GetScalarPointer() );
                                        GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
                                        if (iLst!=0)
                                        {
-                                               acumDiff = acumDiff+abs(vIn-vInBack);
-                                       } 
-                                       vInBack=vIn;
+                        if (bbGetInputType()==20)
+                        {
+                            acumDiff = acumDiff+abs(vIn-vInBack);
+                            vInBack=vIn;
+                        } // if 20
+                        if (bbGetInputType()==21)
+                        {
+                            acumDiff = acumDiff+vIn;
+                        } // if 20
+                                       }
                                } // for iLst
                                acumDiff = acumDiff/sizeLst;
                                SETVALUE2_VTK_CREA(acumDiff,pOut,stOut,index)
index 7eccc8c706dc061ec82365df8e0520087e99af41..9693c1aba188635d116994d587b173a9fc698afa 100644 (file)
@@ -37,7 +37,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(MultipleOperations,bbtk::AtomicBlackBox);
   BBTK_DESCRIPTION("No Description.");
   BBTK_CATEGORY("empty");
   BBTK_INPUT(MultipleOperations,InLst,"List input images ",std::vector<vtkImageData*>,"");
-  BBTK_INPUT(MultipleOperations,Type,"(default 0) 0,   20 average-difference ",int,"");
+  BBTK_INPUT(MultipleOperations,Type,"(default 0) 0:Nothing,   20:Average-difference  21:Average",int,"");
   BBTK_OUTPUT(MultipleOperations,Out,"Output image",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(MultipleOperations);
 //=====