2 // 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)
4 #include "bbcreaVtkApplyMask.h"
5 #include "bbcreaVtkPackage.h"
7 #include "creaVtk_MACROS.h"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ApplyMask)
13 BBTK_BLACK_BOX_IMPLEMENTATION(ApplyMask,bbtk::AtomicBlackBox);
15 // 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)
17 void ApplyMask::Process()
20 // THE MAIN PROCESSING METHOD BODY
21 // Here we simply set the input 'In' value to the output 'Out'
22 // And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 // void bbSet{Input|Output}NAME(const TYPE&)
25 // const TYPE& bbGet{Input|Output}NAME() const
27 // * NAME is the name of the input/output
28 // (the one provided in the attribute 'name' of the tag 'input')
29 // * TYPE is the C++ type of the input/output
30 // (the one provided in the attribute 'type' of the tag 'input')
32 // bbSetOutputOut( bbGetInputIn() );
33 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35 if ((bbGetInputImage()!=NULL) && (bbGetInputMask()!=NULL))
39 vtkImageData *resultImage=NULL;
40 bbGetInputImage()->GetExtent( extImage );
41 bbGetInputImage()->GetExtent( extMask );
42 int dimXImage = extImage[1]-extImage[0]+1;
43 int dimYImage = extImage[3]-extImage[2]+1;
44 int dimZImage = extImage[5]-extImage[4]+1;
45 int dimXMask = extMask[1]-extMask[0]+1;
46 int dimYMask = extMask[3]-extMask[2]+1;
47 int dimZMask = extMask[5]-extMask[4]+1;
49 if (bbGetInputType()==0)
51 if (bbGetOutputOut()!=NULL)
53 bbGetOutputOut()->Delete();
56 resultImage = vtkImageData::New();
57 resultImage->Initialize();
58 resultImage->SetSpacing( bbGetInputImage()->GetSpacing() );
59 resultImage->SetDimensions( dimXImage, dimYImage, dimZImage );
60 resultImage->AllocateScalars( bbGetInputImage()->GetScalarType(),1 );
63 if (bbGetInputType()==1)
65 resultImage=bbGetInputImage();
68 if (bbGetInputType()==2)
70 resultImage=bbGetInputImage();
73 if (bbGetInputType()==3)
75 resultImage=bbGetInputImage();
79 if ((dimXImage==dimXMask) &&
80 (dimYImage==dimYMask) &&
81 (dimZImage==dimZMask))
83 long int i, size = dimXImage * dimYImage * dimZImage;
84 #pragma omp parallel for
87 DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI, bbGetInputImage() );
88 DEF_POINTER_IMAGE_VTK_CREA(vM,ssM,pM,stM, bbGetInputMask() );
89 DEF_POINTER_IMAGE_VTK_CREA(vO,ssO,pO,stO, resultImage );
90 GETVALUE2_VTK_CREA(vM,pM,stM,i);
92 if (bbGetInputType()==0) //Applay mask to new Image
94 GETVALUE2_VTK_CREA(vI,pI,stI,i);
99 vO = bbGetInputBackground();
101 SETVALUE2_VTK_CREA(vO,pO,stO,i);
104 if (bbGetInputType()==1) //Modifiy the Input image with the Label value in Mask place
108 vO = bbGetInputLabel();
109 SETVALUE2_VTK_CREA(vO,pO,stO,i);
113 if (bbGetInputType()==2) //Modifiy the Input image with the Mask value
118 SETVALUE2_VTK_CREA(vO,pO,stO,i);
124 bbSetOutputOut( resultImage );
125 } // if Image && Mask
129 // 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)
131 void ApplyMask::bbUserSetDefaultValues()
134 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
135 // Here we initialize the input 'In' to 0
136 bbSetInputImage(NULL);
137 bbSetInputMask(NULL);
138 bbSetInputBackground(0);
139 bbSetInputLabel(255);
141 bbSetOutputOut(NULL);
145 // 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)
147 void ApplyMask::bbUserInitializeProcessing()
150 // THE INITIALIZATION METHOD BODY :
152 // but this is where you should allocate the internal/output pointers
158 // 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)
160 void ApplyMask::bbUserFinalizeProcessing()
163 // THE FINALIZATION METHOD BODY :
165 // but this is where you should desallocate the internal/output pointers
170 // EO namespace bbcreaVtk