//===== // 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) //===== #include "bbcreaVtkApplyMask.h" #include "bbcreaVtkPackage.h" #include "creaVtk_MACROS.h" namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ApplyMask) BBTK_BLACK_BOX_IMPLEMENTATION(ApplyMask,bbtk::AtomicBlackBox); //===== // 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) //===== void ApplyMask::Process() { // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value // INPUT/OUTPUT ACCESSORS ARE OF THE FORM : // void bbSet{Input|Output}NAME(const TYPE&) // const TYPE& bbGet{Input|Output}NAME() const // Where : // * NAME is the name of the input/output // (the one provided in the attribute 'name' of the tag 'input') // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <GetExtent( extImage ); bbGetInputMask()->GetExtent( extMask ); 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; double background = bbGetInputBackground(); double bgToAnalice = bbGetInputBackgroundToAnalice(); 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 (bbGetInputType()==3) { resultImage=bbGetInputImage(); } // if Type==3 if ((dimXImage==dimXMask) && (dimYImage==dimYMask) && (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; iModified(); bbSetOutputOut( resultImage ); } else { if (bbGetInputType()==2) { bbSetOutputOut( bbGetInputImage() ); } }// if Image && Mask } //===== // 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) //===== void ApplyMask::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputImage(NULL); bbSetInputMask(NULL); bbSetInputBackground(0); // output image Type 0 bbSetInputBackgroundToAnalice(0); bbSetInputLabel(255); bbSetInputType(0); bbSetOutputOut(NULL); } //===== // 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) //===== void ApplyMask::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any } //===== // 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) //===== void ApplyMask::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbcreaVtk