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 double background = bbGetInputBackground();
50 double bgToAnalice = bbGetInputBackgroundToAnalice();
52 if (bbGetInputType()==0)
54 if (bbGetOutputOut()!=NULL)
56 bbGetOutputOut()->Delete();
59 resultImage = vtkImageData::New();
60 resultImage->Initialize();
61 resultImage->SetSpacing( bbGetInputImage()->GetSpacing() );
62 resultImage->SetDimensions( dimXImage, dimYImage, dimZImage );
63 resultImage->AllocateScalars( bbGetInputImage()->GetScalarType(),1 );
66 if (bbGetInputType()==1)
68 resultImage=bbGetInputImage();
71 if (bbGetInputType()==2)
73 resultImage=bbGetInputImage();
76 if (bbGetInputType()==3)
78 resultImage=bbGetInputImage();
82 if ((dimXImage==dimXMask) &&
83 (dimYImage==dimYMask) &&
84 (dimZImage==dimZMask))
86 long int i, size = dimXImage * dimYImage * dimZImage;
87 #pragma omp parallel for
90 DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI, bbGetInputImage() );
91 DEF_POINTER_IMModifieAGE_VTK_CREA(vM,ssM,pM,stM, bbGetInputMask() );
92 DEF_POINTER_IMAGE_VTK_CREA(vO,ssO,pO,stO, resultImage );
93 GETVALUE2_VTK_CREA(vM,pM,stM,i);
95 if (bbGetInputType()==0) //Applay mask to new Image
97 GETVALUE2_VTK_CREA(vI,pI,stI,i);
104 SETVALUE2_VTK_CREA(vO,pO,stO,i);
107 if (bbGetInputType()==1) //Modifiy the Input image with the Label value in Mask place
111 vO = bbGetInputLabel();
112 SETVALUE2_VTK_CREA(vO,pO,stO,i);
116 if (bbGetInputType()==2) //Modifiy the Input image with the Mask value
121 SETVALUE2_VTK_CREA(vO,pO,stO,i);
127 resultImage->Modified();
128 bbSetOutputOut( resultImage );
129 } // if Image && Mask
132 // 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)
134 void ApplyMask::bbUserSetDefaultValues()
137 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
138 // Here we initialize the input 'In' to 0
139 bbSetInputImage(NULL);
140 bbSetInputMask(NULL);
141 bbSetInputBackground(0); // output image Type 0
142 bbSetInputBackgroundToAnalice(0);
143 bbSetInputLabel(255);
145 bbSetOutputOut(NULL);
149 // 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)
151 void ApplyMask::bbUserInitializeProcessing()
154 // THE INITIALIZATION METHOD BODY :
156 // but this is where you should allocate the internal/output pointers
162 // 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)
164 void ApplyMask::bbUserFinalizeProcessing()
167 // THE FINALIZATION METHOD BODY :
169 // but this is where you should desallocate the internal/output pointers
174 // EO namespace bbcreaVtk