]> Creatis software - creaVtk.git/commitdiff
#3329 creaVtk Feature New Normal - new options for Applay mask box
authorEduardo DAVILA <davila@localhost.localdomain>
Fri, 20 Dec 2019 07:48:27 +0000 (08:48 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Fri, 20 Dec 2019 07:48:27 +0000 (08:48 +0100)
bbtk_creaVtk_PKG/src/bbcreaVtkApplyMask.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkApplyMask.h

index 264f55e4a42562403d1ade926ea4eda0e33d5646..74a7ce55d491baea85bcc891cab86fbd9d05cc62 100644 (file)
@@ -34,56 +34,91 @@ void ApplyMask::Process()
 
        if ((bbGetInputImage()!=NULL) && (bbGetInputMask()!=NULL))
        {
-               int extImage[6];
+               int                     extImage[6];
+               int                     extMask[6];
+               vtkImageData    *resultImage=NULL;
                bbGetInputImage()->GetExtent( extImage );
-               int dimXImage = extImage[1]-extImage[0]+1;
-               int dimYImage = extImage[3]-extImage[2]+1;
-               int dimZImage = extImage[5]-extImage[4]+1;
-
-               int extMask[6];
                bbGetInputImage()->GetExtent( extMask );
-               int dimXMask = extMask[1]-extMask[0]+1;
-               int dimYMask = extMask[3]-extMask[2]+1;
-               int dimZMask = extMask[5]-extMask[4]+1;
+               int dimXImage   = extImage[1]-extImage[0]+1;
+               int dimYImage   = extImage[3]-extImage[2]+1;
+               int dimZImage   = extImage[5]-extImage[4]+1;
+               int dimXMask    = extMask[1]-extMask[0]+1;
+               int dimYMask    = extMask[3]-extMask[2]+1;
+               int dimZMask    = extMask[5]-extMask[4]+1;
+
+               if (bbGetInputType()==0)
+               {
+                       if (bbGetOutputOut()!=NULL) 
+                       {
+                               bbGetOutputOut()->Delete();
+                       }       
+
+                       resultImage = vtkImageData::New();
+                       resultImage->Initialize();
+                       resultImage->SetSpacing( bbGetInputImage()->GetSpacing() );
+                       resultImage->SetDimensions(  dimXImage, dimYImage, dimZImage );
+                       resultImage->AllocateScalars( bbGetInputImage()->GetScalarType(),1 );
+               } // if Type==0                 
 
+               if (bbGetInputType()==1)
+               {
+                       resultImage=bbGetInputImage();
+               } // if Type==1
+
+               if (bbGetInputType()==2)
+               {
+                       resultImage=bbGetInputImage();
+               } // if Type==2
 
-               if (bbGetOutputOut()!=NULL) 
+               if (bbGetInputType()==3)
                {
-                       bbGetOutputOut()->Delete();
-               }       
+                       resultImage=bbGetInputImage();
+               } // if Type==3
 
-               vtkImageData *resultImage=NULL;
-               resultImage = vtkImageData::New();
-               resultImage->Initialize();
-               resultImage->SetSpacing( bbGetInputImage()->GetSpacing() );
-               resultImage->SetDimensions(  dimXImage, dimYImage, dimZImage );
-               resultImage->AllocateScalars( bbGetInputImage()->GetScalarType(),1 );
-                       
 
                if ((dimXImage==dimXMask) &&
                        (dimYImage==dimYMask) &&
                        (dimZImage==dimZMask)) 
                        {
-
-
                                long int i, size = dimXImage * dimYImage * dimZImage;
                                #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(vI,pI,stI,i);
                                        GETVALUE2_VTK_CREA(vM,pM,stM,i);
-                                       if (vM!=0)
-                                       {
-                                               vO = vI;
-                                       } else {
-                                               vO = bbGetInputBackground(); 
-                                       }
-                                       SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+
+                                       if (bbGetInputType()==0)  //Applay mask to new Image
+                                       {               
+                                               GETVALUE2_VTK_CREA(vI,pI,stI,i);
+                                               if (vM!=0)
+                                               {
+                                                       vO = vI;
+                                               } else {
+                                                       vO = bbGetInputBackground(); 
+                                               }
+                                               SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+                                       } // if Type==0
+
+                                       if (bbGetInputType()==1)  //Modifiy the Input image with the Label value in Mask place
+                                       {               
+                                               if (vM!=0)
+                                               {
+                                                       vO = bbGetInputLabel();
+                                                       SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+                                               }
+                                       } // if Type==0
+
+                                       if (bbGetInputType()==2)  //Modifiy the Input image with the Mask value
+                                       {               
+                                               if (vM!=0)
+                                               {
+                                                       vO = vM;
+                                                       SETVALUE2_VTK_CREA(vO,pO,stO,i);        
+                                               }
+                                       } // if Type==0
+
                                } // for
                } //if dim
        bbSetOutputOut( resultImage );
@@ -101,6 +136,8 @@ void ApplyMask::bbUserSetDefaultValues()
    bbSetInputImage(NULL);
    bbSetInputMask(NULL);
    bbSetInputBackground(0);
+   bbSetInputLabel(255);
+   bbSetInputType(0);
    bbSetOutputOut(NULL);
   
 }
index 0026fbe065712e6d1acbc2e0c0072f01390e6fa2..687426a4827856233be4820d906cba7c702be009 100644 (file)
@@ -21,8 +21,10 @@ class bbcreaVtk_EXPORT ApplyMask
 // 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)
 //===== 
   BBTK_DECLARE_INPUT(Background,double);
+  BBTK_DECLARE_INPUT(Label,double);
   BBTK_DECLARE_INPUT(Image,vtkImageData*);
   BBTK_DECLARE_INPUT(Mask,vtkImageData*);
+  BBTK_DECLARE_INPUT(Type,int);
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
   BBTK_PROCESS(Process);
   void Process();
@@ -37,8 +39,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ApplyMask,bbtk::AtomicBlackBox);
   BBTK_DESCRIPTION("No Description.");
   BBTK_CATEGORY("empty");
   BBTK_INPUT(ApplyMask,Background,"Background value",double,"");
+  BBTK_INPUT(ApplyMask,Label,"(double 255)  Label value (type 1,2)",double,"");
   BBTK_INPUT(ApplyMask,Image,"Input image",vtkImageData*,"");
   BBTK_INPUT(ApplyMask,Mask,"Input mask",vtkImageData*,"");
+  BBTK_INPUT(ApplyMask,Type,"(default 0) 0:Create new image  1:Modify the Image input with Label value at the mask place   2: Modify the Image input with the value of the mask",int,"");
   BBTK_OUTPUT(ApplyMask,Out,"Output image",vtkImageData*,"");
 BBTK_END_DESCRIBE_BLACK_BOX(ApplyMask);
 //=====