From: Eduardo DAVILA Date: Fri, 21 Jan 2022 16:05:44 +0000 (+0100) Subject: #3479 LaplacianFilter box and ImageToPoints box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f617a7b45a3c98d373fad9023fabe1626807460f;p=creaVtk.git #3479 LaplacianFilter box and ImageToPoints box --- diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageLaplacian.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageLaplacian.cxx new file mode 100644 index 0000000..24dbf37 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageLaplacian.cxx @@ -0,0 +1,81 @@ +//===== +// 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 "bbcreaVtkImageLaplacian.h" +#include "bbcreaVtkPackage.h" + +#include "vtkImageLaplacian.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageLaplacian) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageLaplacian,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 ImageLaplacian::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 ( bbGetInputIn()!=NULL ) + { + vtkImageLaplacian *laplacian =vtkImageLaplacian::New(); + laplacian->SetInputData( bbGetInputIn() ); + laplacian->Update(); + bbSetOutputOut( laplacian->GetOutput() ); + } else { + bbSetOutputOut( NULL ); + }// if In +} + +//===== +// 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 ImageLaplacian::bbUserSetDefaultValues() +{ +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(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 ImageLaplacian::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 ImageLaplacian::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageLaplacian.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageLaplacian.h new file mode 100644 index 0000000..00cc34a --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageLaplacian.h @@ -0,0 +1,46 @@ +//===== +// 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) +//===== +#ifndef __bbcreaVtkImageLaplacian_h_INCLUDED__ +#define __bbcreaVtkImageLaplacian_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include "vtkImageData.h" +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ImageLaplacian + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageLaplacian,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) +//===== + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); +//===== +// 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_BEGIN_DESCRIBE_BLACK_BOX(ImageLaplacian,bbtk::AtomicBlackBox); +BBTK_NAME("ImageLaplacian"); +BBTK_AUTHOR("InfoDev"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); +BBTK_INPUT(ImageLaplacian,In,"Input image",vtkImageData*,""); +BBTK_OUTPUT(ImageLaplacian,Out,"Output image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageLaplacian); +//===== +// 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) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkImageLaplacian_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageToLstPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageToLstPoints.cxx new file mode 100644 index 0000000..041b79e --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageToLstPoints.cxx @@ -0,0 +1,141 @@ +//===== +// 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 "bbcreaVtkImageToLstPoints.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageToLstPoints) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageToLstPoints,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 ImageToLstPoints::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') + + std::vector lstX; + std::vector lstY; + std::vector lstZ; + std::vector lstValues; + vtkImageData *img=bbGetInputIn(); + if (img!=NULL) + { + int dim[3]; + int ext[6]; + img->GetExtent(ext); + dim[0] = ext[1]-ext[0]+1; + dim[1] = ext[3]-ext[2]+1; + dim[2] = ext[5]-ext[4]+1; + std::vector lstExt = bbGetInputExtent(); + if (lstExt.size()!=6) + { + lstExt.clear(); + for (int i=0; i<6; i++) lstExt.push_back( ext[i] ); + } else { + + if (lstExt[0]<0) lstExt[0] = 0; + if (lstExt[1]>=dim[0]) lstExt[1] = dim[0]-1; + if (lstExt[2]<0) lstExt[2] = 0; + if (lstExt[3]>=dim[1]) lstExt[3] = dim[1]-1; + if (lstExt[4]<0) lstExt[4] = 0; + if (lstExt[5]>=dim[2]) lstExt[5] = dim[2]-1; + } // if lstExt size + double range[2]; + img->GetScalarRange(range); + std::vector lstRange = bbGetInputRange(); + if (lstRange.size()!=2) + { + lstRange.clear(); + for (int i=0; i<2; i++) lstRange.push_back( range[i] ); + } // if lstRange size + + double background=bbGetInputBackground(); + int x,y,z; + double value; + for (z=lstExt[4] ; z<=lstExt[5] ; z++) + { + for (y=lstExt[2] ; y<=lstExt[3] ; y++) + { + for (x=lstExt[0] ; x<=lstExt[1] ; x++) + { + value = img->GetScalarComponentAsDouble(x,y,z,0); + if ((value>=lstRange[0]) && (value<=lstRange[1])) + { + lstX.push_back(x); + lstY.push_back(y); + lstZ.push_back(z); + lstValues.push_back(value); + } else { + if ( bbGetInputType() == 1 ) + { + lstX.push_back(x); + lstY.push_back(y); + lstZ.push_back(z); + lstValues.push_back(background); + } + }// if value + }// for x + }// for y + }// for z + + } // if bbGetInputIn() + bbSetOutputLstPointsX( lstX ); + bbSetOutputLstPointsY( lstY ); + bbSetOutputLstPointsZ( lstZ ); + bbSetOutputLstValues( lstValues ); +} + +//===== +// 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 ImageToLstPoints::bbUserSetDefaultValues() +{ +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(NULL); + bbSetInputType(0); + bbSetInputBackground(0); +} + +//===== +// 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 ImageToLstPoints::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 ImageToLstPoints::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaVtk + + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageToLstPoints.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageToLstPoints.h new file mode 100644 index 0000000..39caa1a --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageToLstPoints.h @@ -0,0 +1,61 @@ +//===== +// 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) +//===== +#ifndef __bbcreaVtkImageToLstPoints_h_INCLUDED__ +#define __bbcreaVtkImageToLstPoints_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" +#include "vtkImageData.h" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ImageToLstPoints + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageToLstPoints,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) +//===== + BBTK_DECLARE_INPUT(In,vtkImageData*); + BBTK_DECLARE_INPUT(Extent,std::vector); + BBTK_DECLARE_INPUT(Range,std::vector); + BBTK_DECLARE_INPUT(Background,double); + BBTK_DECLARE_INPUT(Type,int); + BBTK_DECLARE_OUTPUT(LstPointsX,std::vector); + BBTK_DECLARE_OUTPUT(LstPointsY,std::vector); + BBTK_DECLARE_OUTPUT(LstPointsZ,std::vector); + BBTK_DECLARE_OUTPUT(LstValues,std::vector); + BBTK_PROCESS(Process); + void Process(); +//===== +// 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_BEGIN_DESCRIBE_BLACK_BOX(ImageToLstPoints,bbtk::AtomicBlackBox); + BBTK_NAME("ImageToLstPoints"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ImageToLstPoints,In,"Input",vtkImageData*,""); + BBTK_INPUT(ImageToLstPoints,Extent,"(default extent image) [minX maxX minY maxY minZ maxZ]",std::vector,""); + BBTK_INPUT(ImageToLstPoints,Range,"(default range image) [min max] ",std::vector,""); + BBTK_INPUT(ImageToLstPoints,Type,"(default 0) 0:Just the Range values 1:All point, put 0 in value for the outrange points",int,""); + BBTK_INPUT(ImageToLstPoints,Background,"'(default 0) for Type 1",double,""); + BBTK_OUTPUT(ImageToLstPoints,LstPointsX,"List of X",std::vector,""); + BBTK_OUTPUT(ImageToLstPoints,LstPointsY,"List of Y",std::vector,""); + BBTK_OUTPUT(ImageToLstPoints,LstPointsZ,"List of Z",std::vector,""); + BBTK_OUTPUT(ImageToLstPoints,LstValues,"List of Z",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageToLstPoints); +//===== +// 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) +//===== +} +// EO namespace bbcreaVtk + +#endif // __bbcreaVtkImageToLstPoints_h_INCLUDED__ +