From: reyes Date: Mon, 20 Jun 2011 11:56:45 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a53ddc439cc5056ae182f2ecbbd84a7c1d2b0f9e;p=bbtk.git *** empty log message *** --- diff --git a/packages/vtk/src/bbvtkBinaryOperations.cxx b/packages/vtk/src/bbvtkBinaryOperations.cxx index abf08b8..cedf22e 100644 --- a/packages/vtk/src/bbvtkBinaryOperations.cxx +++ b/packages/vtk/src/bbvtkBinaryOperations.cxx @@ -70,7 +70,7 @@ void BinaryOperations::Process() bbSignalOutputModification(); } - + void BinaryOperations::bbUserSetDefaultValues() { @@ -82,10 +82,9 @@ void BinaryOperations::bbUserSetDefaultValues() bbSetOutputOut(NULL); bbSetInputOperation(0); ope = vtkImageMathematics::New(); - constante = NULL; } - - + + void BinaryOperations::bbUserInitializeProcessing() { @@ -95,8 +94,8 @@ void BinaryOperations::bbUserInitializeProcessing() // if any } - - + + void BinaryOperations::bbUserFinalizeProcessing() { diff --git a/packages/vtk/src/bbvtkBinaryOperations.h b/packages/vtk/src/bbvtkBinaryOperations.h index 623d039..db26ec8 100644 --- a/packages/vtk/src/bbvtkBinaryOperations.h +++ b/packages/vtk/src/bbvtkBinaryOperations.h @@ -36,7 +36,6 @@ class bbvtk_EXPORT BinaryOperations bbtkStaticLecture lector; vtkImageMathematics* ope; - vtkImageData* constante; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryOperations,bbtk::AtomicBlackBox); @@ -44,8 +43,8 @@ BBTK_NAME("BinaryOperations"); BBTK_AUTHOR("Info-Dev"); BBTK_DESCRIPTION("Math operation between two images"); BBTK_CATEGORY("filter"); -BBTK_INPUT(BinaryOperations,In1,"",vtkImageData*,""); -BBTK_INPUT(BinaryOperations,In2,"",vtkImageData*,""); +BBTK_INPUT(BinaryOperations,In1,"first image to be operated",vtkImageData*,"NULL default"); +BBTK_INPUT(BinaryOperations,In2,"second image to be operated",vtkImageData*,"NULL default"); BBTK_INPUT(BinaryOperations,Operation,"0:Add (default) , 1:subtract, 2:multiply, 3:divide",int,""); BBTK_OUTPUT(BinaryOperations,Out,"",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(BinaryOperations); diff --git a/packages/vtk/src/bbvtkSimpleMathematics.cxx b/packages/vtk/src/bbvtkSimpleMathematics.cxx deleted file mode 100644 index 765d06f..0000000 --- a/packages/vtk/src/bbvtkSimpleMathematics.cxx +++ /dev/null @@ -1,436 +0,0 @@ -#include "bbvtkSimpleMathematics.h" -#include "bbvtkPackage.h" -namespace bbvtk -{ - - void StaticLecture::setPixelValue(int i, int j, int k, vtkImageData* img, double value) - { - //double rta; - int scalar_type = img->GetScalarType(); - int* ext = img->GetExtent(); - if (i < ext[0]) - return; - if (i > ext[1]) - return; - - if (j < ext[2]) - return; - if (j > ext[3]) - return; - - if (k < ext[4]) - return; - if (k > ext[5]) - return; - - switch (scalar_type) - { - case VTK_CHAR: - char * ap2; - ap2 = (char *) img->GetScalarPointer(i,j,k); - *ap2 = (char) value; - break; - case VTK_UNSIGNED_CHAR: - unsigned char * ap3; - ap3 = (unsigned char *) img->GetScalarPointer(i,j,k); - *ap3 = (unsigned char) value; - break; - case VTK_SHORT: - short * ap4; - ap4 = (short *) img->GetScalarPointer(i,j,k); - *ap4 = (short) value; - break; - case VTK_UNSIGNED_SHORT: - unsigned short * ap5; - ap5 = (unsigned short *) img->GetScalarPointer(i,j,k); - *ap5 = (unsigned short) value; - break; - case VTK_INT: - int * ap6; - ap6 = (int *) img->GetScalarPointer(i,j,k); - *ap6 = (int) value; - break; - case VTK_UNSIGNED_INT: - unsigned int * ap7; - ap7 = (unsigned int *) img->GetScalarPointer(i,j,k); - *ap7 = (unsigned int) value; - break; - case VTK_LONG: - long * ap8; - ap8 = (long *) img->GetScalarPointer(i,j,k); - *ap8 = (long) value; - break; - case VTK_UNSIGNED_LONG: - unsigned long * ap9; - ap9 = (unsigned long *) img->GetScalarPointer(i,j,k); - *ap9 = (unsigned long) value; - break; - case VTK_FLOAT: - float * ap10; - ap10 = (float *) img->GetScalarPointer(i,j,k); - *ap10 = (float) value; - break; - case VTK_DOUBLE: - double * ap11; - ap11 = (double *) img->GetScalarPointer(i,j,k); - *ap11 = (double) value; - break; - } - } - - double StaticLecture::getPixelValue(int i, int j, int k, vtkImageData* img) - { - double rta; - int scalar_type = img->GetScalarType(); - int* ext = img->GetExtent(); - if (i < ext[0]) - i=ext[0]; - if (i > ext[1]) - i=ext[1]; - - if (j < ext[2]) - j=ext[2]; - if (j > ext[3]) - j=ext[3]; - - if (k < ext[4]) - k=ext[4]; - if (k > ext[5]) - k=ext[5]; - - switch (scalar_type) - { - case VTK_CHAR: - char * ap2; - ap2 = (char *) img->GetScalarPointer(i,j,k); - rta = (double) *ap2; - break; - case VTK_UNSIGNED_CHAR: - unsigned char * ap3; - ap3 = (unsigned char *) img->GetScalarPointer(i,j,k); - rta = (double) *ap3; - break; - case VTK_SHORT: - short * ap4; - ap4 = (short *) img->GetScalarPointer(i,j,k); - rta = (double) *ap4; - break; - case VTK_UNSIGNED_SHORT: - unsigned short * ap5; - ap5 = (unsigned short *) img->GetScalarPointer(i,j,k); - rta = (double) *ap5; - break; - case VTK_INT: - int * ap6; - ap6 = (int *) img->GetScalarPointer(i,j,k); - rta = (double) *ap6; - break; - case VTK_UNSIGNED_INT: - unsigned int * ap7; - ap7 = (unsigned int *) img->GetScalarPointer(i,j,k); - rta = (double) *ap7; - break; - case VTK_LONG: - long * ap8; - ap8 = (long *) img->GetScalarPointer(i,j,k); - rta = (double) *ap8; - break; - case VTK_UNSIGNED_LONG: - unsigned long * ap9; - ap9 = (unsigned long *) img->GetScalarPointer(i,j,k); - rta = (double) *ap9; - break; - case VTK_FLOAT: - float * ap10; - ap10 = (float *) img->GetScalarPointer(i,j,k); - rta = (double) *ap10; - break; - case VTK_DOUBLE: - double * ap11; - ap11 = (double *) img->GetScalarPointer(i,j,k); - rta = (double) *ap11; - break; - } - return rta; - } - -BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SimpleMathematics) -BBTK_BLACK_BOX_IMPLEMENTATION(SimpleMathematics,bbtk::AtomicBlackBox); -void SimpleMathematics::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') - - if (bbGetInputIn1() == NULL) - { - std::cout << "Set In1 at least" << std::endl; - return; - } - - ope->SetInput1((vtkDataObject*)bbGetInputIn1()); - bool onlyone = true; - - if (bbGetInputIn2() != NULL) - { - ope->SetInput2((vtkDataObject*)bbGetInputIn2()); - onlyone = false; - } - - ope->SetConstantK(bbGetInputInConstant()); - ope->SetConstantC(bbGetInputInConstant()); - - switch (bbGetInputOperation()) - { - case 0: - if (onlyone) - ope->SetOperationToAddConstant(); - else - ope->SetOperationToAdd(); - break; - case 1: - if (onlyone) - { - crearPredeterminado(); - ope->SetInput2((vtkDataSet*) constante); - ope->SetOperationToSubtract(); - } - else - { - ope->SetOperationToSubtract(); - } - break; - case 2: - if (onlyone) - ope->SetOperationToMultiply(); - else - ope->SetOperationToMultiplyByK(); - break; - case 3: - if (onlyone) - { - std::cout << "Set In2" << std::endl; - return; - } - else - { - ope->SetOperationToDivide(); - } - break; - case 4: - ope->SetOperationToInvert(); - break; - case 9: - ope->SetOperationToAbsoluteValue(); - break; - case 5: - if (onlyone) - { - std::cout << "Set In2" << std::endl; - return; - } - else - { - ope->SetOperationToSin(); - } - break; - case 6: - if (onlyone) - { - std::cout << "Set In2" << std::endl; - return; - } - else - { - ope->SetOperationToCos(); - } - break; - case 7: - if (onlyone) - { - std::cout << "Set In2" << std::endl; - return; - } - else - { - ope->SetOperationToExp(); - } - break; - case 8: - if (onlyone) - { - std::cout << "Set In2" << std::endl; - return; - } - else - { - ope->SetOperationToLog(); - } - break; - case 10: - substractWithMinimum(); - bbSetOutputOut(constante); - return; - break; - case 11: - MultiplyBy(); - bbSetOutputOut(constante); - return; - break; - default: - std::cout << "Invalid Operation" << std::endl; - return; - break; - } - - ope->Update(); - vtkImageData* salida = ope->GetOutput(); - - bbSetOutputOut(salida); - bbSignalOutputModification(); - -} -void SimpleMathematics::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 SimpleMathematics::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 SimpleMathematics::MultiplyBy() -{ - 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 SimpleMathematics::bbUserSetDefaultValues() -{ - -// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX -// Here we initialize the input 'In' to 0 - bbSetInputIn1(NULL); - bbSetInputIn2(NULL); - bbSetOutputOut(NULL); - bbSetInputInConstant(0); - ope = vtkImageMathematics::New(); - constante = NULL; -} -void SimpleMathematics::bbUserInitializeProcessing() -{ - -// THE INITIALIZATION METHOD BODY : -// Here does nothing -// but this is where you should allocate the internal/output pointers -// if any - - -} -void SimpleMathematics::bbUserFinalizeProcessing() -{ - -// THE FINALIZATION METHOD BODY : -// Here does nothing -// but this is where you should desallocate the internal/output pointers -// if any - -} -} -// EO namespace bbvtk - - diff --git a/packages/vtk/src/bbvtkSimpleMathematics.h b/packages/vtk/src/bbvtkSimpleMathematics.h deleted file mode 100644 index f4a0084..0000000 --- a/packages/vtk/src/bbvtkSimpleMathematics.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __bbvtkSimpleMathematics_h_INCLUDED__ -#define __bbvtkSimpleMathematics_h_INCLUDED__ -#include "bbvtk_EXPORT.h" -#include "bbtkAtomicBlackBox.h" -#include "iostream" - - -#include -#include -#include -#include - - -namespace bbvtk -{ - - -class StaticLecture -{ -public: - void setPixelValue(int i, int j, int k, vtkImageData* img, double value); - double getPixelValue(int i, int j, int k, vtkImageData* img); -}; - - -class bbvtk_EXPORT SimpleMathematics - : - public bbtk::AtomicBlackBox -{ - BBTK_BLACK_BOX_INTERFACE(SimpleMathematics,bbtk::AtomicBlackBox); - BBTK_DECLARE_INPUT(In1,vtkImageData*); - BBTK_DECLARE_INPUT(In2,vtkImageData*); - BBTK_DECLARE_INPUT(Operation,int); - BBTK_DECLARE_INPUT(InConstant,double); - BBTK_DECLARE_OUTPUT(Out,vtkImageData*); - BBTK_PROCESS(Process); - void Process(); - - void crearPredeterminado(); - void substractWithMinimum(); - void MultiplyBy(); - - StaticLecture lector; - - vtkImageMathematics* ope; - vtkImageData* constante; -}; - -BBTK_BEGIN_DESCRIBE_BLACK_BOX(SimpleMathematics,bbtk::AtomicBlackBox); -BBTK_NAME("SimpleMathematics"); -BBTK_AUTHOR("_author_"); -BBTK_DESCRIPTION("_description_"); -BBTK_CATEGORY("__CATEGORY__"); -BBTK_INPUT(SimpleMathematics,In1,"",vtkImageData*,""); -BBTK_INPUT(SimpleMathematics,In2,"",vtkImageData*,""); -BBTK_INPUT(SimpleMathematics,InConstant,"",double,""); -BBTK_INPUT(SimpleMathematics,Operation,"0:Add, 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs",int,""); -BBTK_OUTPUT(SimpleMathematics,Out,"",vtkImageData*,""); -BBTK_END_DESCRIBE_BLACK_BOX(SimpleMathematics); -} -// EO namespace bbSimpleProcessing - -#endif // __bbvtkSimpleMathematics_h_INCLUDED__ - - diff --git a/packages/vtk/src/bbvtkUnaryOperations.cxx b/packages/vtk/src/bbvtkUnaryOperations.cxx index 7424ccd..bcf168d 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.cxx +++ b/packages/vtk/src/bbvtkUnaryOperations.cxx @@ -99,7 +99,7 @@ void UnaryOperations::Process() bbSignalOutputModification(); } - + /* Borrame Eduardo - Juan Pablo void UnaryOperations::crearPredeterminado() { @@ -131,7 +131,7 @@ void UnaryOperations::crearPredeterminado() } */ - + void UnaryOperations::substractWithMinimum() { int ext[6]; @@ -168,41 +168,6 @@ void UnaryOperations::substractWithMinimum() } } -void UnaryOperations::MultiplyBy() -{ - 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() { @@ -210,7 +175,6 @@ void UnaryOperations::bbUserSetDefaultValues() // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputIn1(NULL); -// bbSetInputIn2(NULL); bbSetOutputOut(NULL); bbSetInputInConstant(0); bbSetInputOperation(0); diff --git a/packages/vtk/src/bbvtkUnaryOperations.h b/packages/vtk/src/bbvtkUnaryOperations.h index 1f13180..fddd758 100644 --- a/packages/vtk/src/bbvtkUnaryOperations.h +++ b/packages/vtk/src/bbvtkUnaryOperations.h @@ -45,9 +45,9 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(UnaryOperations,bbtk::AtomicBlackBox); BBTK_AUTHOR("Info-Dev Creatis"); BBTK_DESCRIPTION("math operation over an image"); BBTK_CATEGORY("filtre"); - BBTK_INPUT(UnaryOperations,In1,"",vtkImageData*,""); - BBTK_INPUT(UnaryOperations,InConstant,"",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",int,""); + 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",int,"Addition default"); BBTK_OUTPUT(UnaryOperations,Out,"",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(UnaryOperations); }