]> Creatis software - creaVtk.git/commitdiff
#3414 creaVtk Feature New Normal - openmp
authorEduardo DAVILA <davila@localhost.localdomain>
Mon, 27 Apr 2020 08:41:10 +0000 (10:41 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Mon, 27 Apr 2020 08:41:10 +0000 (10:41 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkApplyMask.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.h

index 0424c5e81278d4a9cd6bf5bdb0e62ccb526b2dbb..463ee223014c2fef4b19ff71ea3bca51abb7608f 100644 (file)
@@ -84,41 +84,54 @@ void ApplyMask::Process()
                        (dimZImage==dimZMask)) 
                        {
                                long int i, size = dimXImage * dimYImage * dimZImage;
+                               DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI, bbGetInputImage() );
+                               DEF_POINTER_IMAGE_VTK_CREA(vM,ssM,pM,stM, bbGetInputMask() );
+                               DEF_POINTER_IMAGE_VTK_CREA(vO,ssO,pO,stO, resultImage );
+
+long int k1omp=(double)(size-1)*0.0;
+long int k2omp=(double)(size-1)*0.2;
+long int k3omp=(double)(size-1)*0.4;
+long int k4omp=(double)(size-1)*0.6;
+long int k5omp=(double)(size-1)*0.8;
+long int k6omp=(double)(size-1)*1.0;
+printf("EED ApplyMask::Process (with openmp)\n");
                                #pragma omp parallel for 
                                for (i=0; i<size;i++)
                                {
-                                       DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI, bbGetInputImage() );
-                                       DEF_POINTER_IMAGE_VTK_CREA(vM,ssM,pM,stM, bbGetInputMask() );
-                                       DEF_POINTER_IMAGE_VTK_CREA(vO,ssO,pO,stO, resultImage );
-                                       GETVALUE2_VTK_CREA(vM,pM,stM,i);
+if ( (k1omp==i) || (k2omp==i) || (k3omp==i) || 
+     (k4omp==i) || (k5omp==i) || (k6omp==i) ) { printf("  %d%\n", (int)(((double)i/(double)(size-1))*100 )); }
+                                       double vItmpOMP;
+                                       double vMtmpOMP;
+                                       double vOtmpOMP;
+                                       GETVALUE2_VTK_CREA(vMtmpOMP,pM,stM,i);
 
                                        if (bbGetInputType()==0)  //Applay mask to new Image
                                        {               
-                                               GETVALUE2_VTK_CREA(vI,pI,stI,i);
-                                               if (vM!=bgToAnalice)
+                                               GETVALUE2_VTK_CREA(vItmpOMP,pI,stI,i);
+                                               if (vMtmpOMP!=bgToAnalice)
                                                {
-                                                       vO = vI;
+                                                       vOtmpOMP = vItmpOMP;
                                                } else {
-                                                       vO = background; 
+                                                       vOtmpOMP = background; 
                                                } // if vM
-                                               SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+                                               SETVALUE2_VTK_CREA(vOtmpOMP,pO,stO,i);  
                                        } // if Type==0
 
                                        if (bbGetInputType()==1)  //Modifiy the Input image with the Label value in Mask place
                                        {               
-                                               if (vM!=bgToAnalice)
+                                               if (vMtmpOMP!=bgToAnalice)
                                                {
-                                                       vO = bbGetInputLabel();
-                                                       SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+                                                       vOtmpOMP = bbGetInputLabel();
+                                                       SETVALUE2_VTK_CREA(vOtmpOMP,pO,stO,i);  
                                                }
                                        } // if Type==1
 
                                        if (bbGetInputType()==2)  //Modifiy the Input image with the Mask value
                                        {               
-                                               if (vM!=bgToAnalice)
+                                               if (vMtmpOMP!=bgToAnalice)
                                                {
-                                                       vO = vM;
-                                                       SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+                                                       vOtmpOMP = vMtmpOMP;
+                                                       SETVALUE2_VTK_CREA(vOtmpOMP,pO,stO,i);  
                                                }
                                        } // if Type==2
 
index c409205ddc0f70a7ccc648a8ecbb4da6e88ed794..d0b96a15548692e1ca28da674cc19467f5c5798b 100644 (file)
@@ -68,17 +68,30 @@ void MagnitudVector::Process()
                DEF_POINTER_IMAGE_VTK_CREA(vvZ,ssvZ,pvZ,stvZ,bbGetInputvZ() )   
                DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput )  
                long int i, size=dim[0]*dim[1]*dim[2];
-#pragma omp parallel for
+
+long int k1omp=(double)(size-1)*0.0;
+long int k2omp=(double)(size-1)*0.2;
+long int k3omp=(double)(size-1)*0.4;
+long int k4omp=(double)(size-1)*0.6;
+long int k5omp=(double)(size-1)*0.8;
+long int k6omp=(double)(size-1)*1.0;
+printf("EED MagnitudVector::Process (with openmp)\n");
+               #pragma omp parallel for
                for (i=0; i<size; i++)
                {
-                       GETVALUE2_VTK_CREA(vvX,pvX,stvX,i) 
-                       GETVALUE2_VTK_CREA(vvY,pvY,stvY,i) 
-                       GETVALUE2_VTK_CREA(vvZ,pvZ,stvZ,i) 
-                       if ( (vvX==0) && (vvY==0) &&(vvZ==0) ) 
+if ( (k1omp==i) || (k2omp==i) || (k3omp==i) || 
+     (k4omp==i) || (k5omp==i) || (k6omp==i) ) { printf("  %d%\n", (int)(((double)i/(double)(size-1))*100 )); }
+                       double vvXtmpOMP;
+                       double vvYtmpOMP;
+                       double vvZtmpOMP;
+                       GETVALUE2_VTK_CREA(vvXtmpOMP,pvX,stvX,i) 
+                       GETVALUE2_VTK_CREA(vvYtmpOMP,pvY,stvY,i) 
+                       GETVALUE2_VTK_CREA(vvZtmpOMP,pvZ,stvZ,i) 
+                       if ( (vvXtmpOMP==0) && (vvYtmpOMP==0) &&(vvZtmpOMP==0) ) 
                        {
                                SETVALUE2_VTK_CREA( 0 ,pOut,stOut,i)
                        } else {
-                               SETVALUE2_VTK_CREA( sqrt(vvX*vvX + vvY*vvY + vvZ*vvZ),pOut,stOut,i)
+                               SETVALUE2_VTK_CREA( sqrt(vvXtmpOMP*vvXtmpOMP + vvYtmpOMP*vvYtmpOMP + vvZtmpOMP*vvZtmpOMP) ,pOut,stOut,i)
                        } // if vvX  vvY  vvZ  != 0
 
                } // for i
index edd549d53153028ae98925caba04849450da240c..fe7b4fab56963e4c5a56b7a50b268c5500363205 100644 (file)
@@ -16,7 +16,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(MultipleOperations,bbtk::AtomicBlackBox);
 //===== 
 void MultipleOperations::Process()
 {
-printf("EED MultipleOperations::Process Start\n");
 // THE MAIN PROCESSING METHOD BODY
 //   Here we simply set the input 'In' value to the output 'Out'
 //   And print out the output value
@@ -37,7 +36,6 @@ printf("EED MultipleOperations::Process Start\n");
                int dimXImage   = extImage[1]-extImage[0]+1;
                int dimYImage   = extImage[3]-extImage[2]+1;
                int dimZImage   = extImage[5]-extImage[4]+1;
-               int iLst,sizeLst= bbGetInputInLst().size();
                if (bbGetOutputOut()!=NULL) 
                {
                        bbGetOutputOut()->Delete();
@@ -48,14 +46,27 @@ printf("EED MultipleOperations::Process Start\n");
                resultImage->SetDimensions(  dimXImage, dimYImage, dimZImage );
                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)
                {
-                       DEF_POINTER_IMAGE_VTK_CREA(vIn ,ssIn ,pIn ,stIn ,bbGetInputInLst()[0] )
-                       DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,resultImage )
-                       double vInBack,acumDiff;
-//  #pragma omp parallel for
+
+long int k1omp=(double)(size-1)*0.0;
+long int k2omp=(double)(size-1)*0.2;
+long int k3omp=(double)(size-1)*0.4;
+long int k4omp=(double)(size-1)*0.6;
+long int k5omp=(double)(size-1)*0.8;
+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++)
                        {
+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
                                {
@@ -73,8 +84,6 @@ printf("EED MultipleOperations::Process Start\n");
                } // if Type==20
                bbSetOutputOut( resultImage );
        } // if InLst size
-printf("EED MultipleOperations::Process End\n");
-
 }
 //===== 
 // 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)
index 44fc699536ac0b99751b3b12a5ae946f81d96ec6..7eccc8c706dc061ec82365df8e0520087e99af41 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 diff ",int,"");
+  BBTK_INPUT(MultipleOperations,Type,"(default 0) 0,   20 average-difference ",int,"");
   BBTK_OUTPUT(MultipleOperations,Out,"Output image",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(MultipleOperations);
 //=====