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 );
bbSetInputImage(NULL);
bbSetInputMask(NULL);
bbSetInputBackground(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)
//=====
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();
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);
//=====