From: davila Date: Wed, 17 Jun 2015 14:27:49 +0000 (+0200) Subject: #2658 BBTK Bug New Normal - Unitary Operation X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtk.git;a=commitdiff_plain;h=6b76f60671eed79e17d8f602878dac4d1928659f #2658 BBTK Bug New Normal - Unitary Operation --- diff --git a/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbg b/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbg new file mode 100644 index 0000000..75a1e87 --- /dev/null +++ b/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbg @@ -0,0 +1,170 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBG BlackBox Diagram file +# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbg +# ---------------------------------- + +APP_START +CATEGORY: +DESCRIPTION:Description ?? +AUTHOR:Author ?? +COMPLEXBOX:TRUE +COMPLEXBOXNAME:ApplyMaskWithTransparence +PACKAGENAME:toolsbbtk +COMPLEXOUTPUTS:1 +COMPLEX_PORT +OutImage +-71.833968:-77.907690:-900.000000 +FIN_COMPLEX_PORT +COMPLEXINPUTS:2 +COMPLEX_PORT +maskImage +-155.945750:140.976519:-900.000000 +FIN_COMPLEX_PORT +COMPLEX_PORT +Image +-52.261663:144.599262:-900.000000 +FIN_COMPLEX_PORT +BOXES:12 +BOX +vtk:BinaryOperations:Box06 +ISEXEC:FALSE +-21.965422:21.398218:-900.000000 +23.609578:11.398218:-900.000000 +PORT +Operation:"2" +FIN_BOX +BOX +vtk:ImageVtkProperties:Box16 +ISEXEC:FALSE +-89.759228:16.979477:-900.000000 +-44.184228:6.979477:-900.000000 +FIN_BOX +BOX +vtk:BinaryOperations:Box20 +ISEXEC:FALSE +-74.625874:-54.714389:-900.000000 +-29.050874:-64.714389:-900.000000 +FIN_BOX +BOX +std:GetVectorFloatElement:Box22 +ISEXEC:FALSE +-112.217901:-2.482812:-900.000000 +-41.042901:-12.482812:-900.000000 +PORT +I:"0" +FIN_BOX +BOX +vtk:RescaleSlopeIntercept:Box23 +ISEXEC:FALSE +-177.610123:18.460663:-900.000000 +-106.435123:8.460663:-900.000000 +PORT +OutputFormat:"VTK_DOUBLE" +PORT +Type:"1" +FIN_BOX +BOX +vtk:UnaryOperations:Box24 +ISEXEC:FALSE +-142.749404:-25.417995:-900.000000 +-97.174404:-35.417995:-900.000000 +PORT +InConstant:"1" +PORT +Operation:"11" +FIN_BOX +BOX +vtk:vtkImageDataPointerRelay:Box18 +ISEXEC:FALSE +-171.782936:117.774432:-900.000000 +-100.607936:107.774432:-900.000000 +FIN_BOX +BOX +vtk:vtkImageDataPointerRelay:Box19 +ISEXEC:FALSE +-53.355388:100.244903:-900.000000 +17.819612:90.244903:-900.000000 +FIN_BOX +BOX +vtk:UnaryOperations:Box09 +ISEXEC:FALSE +-157.853849:61.413786:-900.000000 +-112.278849:51.413786:-900.000000 +PORT +Operation:"3" +FIN_BOX +BOX +vtk:ImageVtkProperties:Box10 +ISEXEC:FALSE +-152.556320:102.747202:-900.000000 +-106.981320:92.747202:-900.000000 +FIN_BOX +BOX +std:GetVectorFloatElement:Box11 +ISEXEC:FALSE +-149.145811:85.700627:-900.000000 +-77.970811:75.700627:-900.000000 +PORT +I:"1" +FIN_BOX +BOX +vtk:RescaleSlopeIntercept:Box12 +ISEXEC:FALSE +-160.936834:45.783197:-900.000000 +-89.761834:35.783197:-900.000000 +PORT +OutputFormat:"VTK_DOUBLE" +FIN_BOX +CONNECTIONS:17 +CONNECTION +Box16:MinMax:Box22:In +NumberOfControlPoints:0 +CONNECTION +Box23:Out:Box24:In1 +NumberOfControlPoints:0 +CONNECTION +Box22:Out:Box24:NewValue +NumberOfControlPoints:0 +CONNECTION +Box06:Out:Box20:In2 +NumberOfControlPoints:0 +CONNECTION +Box24:Out:Box20:In1 +NumberOfControlPoints:0 +CONNECTION +maskImage:maskImage:Box18:In +NumberOfControlPoints:0 +CONNECTION +Image:Image:Box19:In +NumberOfControlPoints:0 +CONNECTION +Box19:Out:Box16:In +NumberOfControlPoints:0 +CONNECTION +Box19:Out:Box06:In2 +NumberOfControlPoints:0 +CONNECTION +Box20:Out:OutImage:OutImage +NumberOfControlPoints:0 +CONNECTION +Box18:Out:Box10:In +NumberOfControlPoints:0 +CONNECTION +Box18:Out:Box09:In1 +NumberOfControlPoints:0 +CONNECTION +Box10:MinMax:Box11:In +NumberOfControlPoints:0 +CONNECTION +Box11:Out:Box09:InConstant +NumberOfControlPoints:0 +CONNECTION +Box09:Out:Box12:In +NumberOfControlPoints:0 +CONNECTION +Box12:Out:Box23:In +NumberOfControlPoints:0 +CONNECTION +Box12:Out:Box06:In1 +NumberOfControlPoints:0 +APP_END diff --git a/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbs b/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbs new file mode 100644 index 0000000..da86c15 --- /dev/null +++ b/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbs @@ -0,0 +1,76 @@ +# ---------------------------------- +# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box) +# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbs +# ---------------------------------- + +include std +include itkvtk +include vtk +include std + +define ApplyMaskWithTransparence toolsbbtk + +author "Author ??" +description "Description ??" + +category "" + +new BinaryOperations Box06 + set Box06.Operation "2" + +new ImageVtkProperties Box16 + +new BinaryOperations Box20 + +new GetVectorFloatElement Box22 + set Box22.I "0" + +new RescaleSlopeIntercept Box23 + set Box23.OutputFormat "VTK_DOUBLE" + set Box23.Type "1" + +new UnaryOperations Box24 + set Box24.InConstant "1" + set Box24.Operation "11" + +new vtkImageDataPointerRelay Box18 + +new vtkImageDataPointerRelay Box19 + +new UnaryOperations Box09 + set Box09.Operation "3" + +new ImageVtkProperties Box10 + +new GetVectorFloatElement Box11 + set Box11.I "1" + +new RescaleSlopeIntercept Box12 + set Box12.OutputFormat "VTK_DOUBLE" + + +connect Box16.MinMax Box22.In +connect Box23.Out Box24.In1 +connect Box22.Out Box24.NewValue +connect Box06.Out Box20.In2 +connect Box24.Out Box20.In1 +connect Box19.Out Box16.In +connect Box19.Out Box06.In2 +connect Box18.Out Box10.In +connect Box18.Out Box09.In1 +connect Box10.MinMax Box11.In +connect Box11.Out Box09.InConstant +connect Box09.Out Box12.In +connect Box12.Out Box23.In +connect Box12.Out Box06.In1 + +# Complex input ports +input maskImage Box18.In " " +input Image Box19.In " " + +# Complex output ports +output OutImage Box20.Out " " + +message + +endefine diff --git a/packages/vtk/src/bbvtkUnaryOperations.cxx b/packages/vtk/src/bbvtkUnaryOperations.cxx index 4f62f1a..706949f 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.cxx +++ b/packages/vtk/src/bbvtkUnaryOperations.cxx @@ -57,20 +57,19 @@ void UnaryOperations::Process() ope->SetInput1((vtkDataObject*)bbGetInputIn1()); - ope->SetConstantK( bbGetInputInConstant() ); -// ope->SetConstantC(bbGetInputInConstant()); - switch (bbGetInputOperation()) { case 0: + ope->SetConstantC( bbGetInputInConstant() ); ope->SetOperationToAddConstant(); break; case 1: - ope->SetConstantK( -1.0 * bbGetInputInConstant() ); + ope->SetConstantC( -1.0 * bbGetInputInConstant() ); ope->SetOperationToAddConstant(); break; case 2: + ope->SetConstantK( bbGetInputInConstant() ); ope->SetOperationToMultiplyByK(); printf("EED UnaryOperations::Process() 2 \n"); @@ -84,20 +83,16 @@ printf("EED UnaryOperations::Process() 3 \n"); ope->SetOperationToInvert(); break; case 5: - ope->SetOperationToSin(); break; case 6: - ope->SetOperationToCos(); break; case 7: - ope->SetOperationToExp(); break; case 8: - ope->SetOperationToLog(); break; case 9: @@ -106,21 +101,14 @@ printf("EED UnaryOperations::Process() 3 \n"); case 10: ope->SetOperationToSquareRoot(); break; + case 11: + ope->SetConstantC( bbGetInputInConstant() ); + ope->SetConstantK( bbGetInputNewValue() ); + ope->SetOperationToReplaceCByK(); + break; -/* EED 21Juin 2011 Borrame - case 10: - substractWithMinimum(); - bbSetOutputOut(constante); - return; - break; - case 11: - MultiplyBy(); - bbSetOutputOut(constante); - return; - break; -*/ default: std::cout << "Invalid Operation" << std::endl; @@ -137,73 +125,6 @@ printf("EED UnaryOperations::Process() 3 \n"); } -/* Borrame Eduardo - Juan Pablo -void UnaryOperations::crearPredeterminado() -{ - int ext[6]; - vtkImageData* inicial = bbGetInputIn1(); - - - if (constante == NULL) - { - inicial->GetExtent(ext); - constante = vtkImageData::New(); - constante->SetExtent(ext); - constante->SetScalarType(inicial->GetScalarType()); - constante->AllocateScalars(); - constante->Update(); - } - - for (int i=ext[0]; i<=ext[1]; i++) - { - for (int j=ext[2]; j<=ext[3]; j++) - { - for (int k=ext[4]; k<=ext[5]; k++) - { - unsigned short* value = (unsigned short*)constante->GetScalarPointer(i,j,k); - *value = bbGetInputInConstant(); - } - } - } -} -*/ - - -void UnaryOperations::substractWithMinimum() -{ - int ext[6]; - double spc[3]; - vtkImageData* inicial = bbGetInputIn1(); - - - if (constante == NULL) - { - inicial->GetExtent(ext); - inicial->GetSpacing(spc); - constante = vtkImageData::New(); - constante->SetExtent(ext); - constante->SetSpacing(spc); - constante->SetOrigin(inicial->GetOrigin()); - constante->SetScalarType(inicial->GetScalarType()); - constante->AllocateScalars(); - constante->Update(); - } - - for (int i=ext[0]; i<=ext[1]; i++) - { - for (int j=ext[2]; j<=ext[3]; j++) - { - for (int k=ext[4]; k<=ext[5]; k++) - { - double temp1 = lector.getPixelValue(i,j,k,inicial); - double temp = temp1 - bbGetInputInConstant(); - if (temp < 0) - temp = 0; - lector.setPixelValue(i,j,k,constante,temp); - } - } - } -} void UnaryOperations::bbUserSetDefaultValues() @@ -214,6 +135,7 @@ void UnaryOperations::bbUserSetDefaultValues() bbSetInputIn1(NULL); bbSetOutputOut(NULL); bbSetInputInConstant(0); + bbSetInputNewValue(0); bbSetInputOperation(0); ope = vtkImageMathematics::New(); constante = NULL; diff --git a/packages/vtk/src/bbvtkUnaryOperations.h b/packages/vtk/src/bbvtkUnaryOperations.h index 82e372f..9ef8725 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.h +++ b/packages/vtk/src/bbvtkUnaryOperations.h @@ -53,6 +53,7 @@ class bbvtk_EXPORT UnaryOperations BBTK_DECLARE_INPUT(In1,vtkImageData*); BBTK_DECLARE_INPUT(Operation,int); BBTK_DECLARE_INPUT(InConstant,double); + BBTK_DECLARE_INPUT(NewValue,double); BBTK_DECLARE_OUTPUT(Out,vtkImageData*); BBTK_PROCESS(Process); void Process(); @@ -74,7 +75,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(UnaryOperations,bbtk::AtomicBlackBox); BBTK_CATEGORY("filtre"); BBTK_INPUT(UnaryOperations,In1,"Image to be operated",vtkImageData*,""); BBTK_INPUT(UnaryOperations,InConstant,"Constant that will be used in the operations.",double,"0 default"); - BBTK_INPUT(UnaryOperations,Operation,"0:Add (Default), 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs????, 10:SquareRoot",int,"Addition default"); + BBTK_INPUT(UnaryOperations,NewValue,"InConstant replace by NewValue",double,"0 default"); + BBTK_INPUT(UnaryOperations,Operation,"0:Add (Default), 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs????, 10:SquareRoot, 11:ReplaceByContant",int,"Addition default"); BBTK_OUTPUT(UnaryOperations,Out,"",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(UnaryOperations); }