From 05159dd0bcaad290f4df98f12b6f7b7cec7121ed Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 3 Feb 2020 16:27:54 +0100 Subject: [PATCH] #3360 creaVtk Feature New Normal - box ImageThreshold --- .../src/bbcreaVtkImageThreshold.cxx | 93 +++++++++++++++++++ .../src/bbcreaVtkImageThreshold.h | 60 ++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.cxx new file mode 100644 index 0000000..a6c35f6 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.cxx @@ -0,0 +1,93 @@ +//===== +// 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 "bbcreaVtkImageThreshold.h" +#include "bbcreaVtkPackage.h" +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageThreshold) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageThreshold,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 ImageThreshold::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 = " <Delete(); + filter=NULL; + } // if + filter = vtkImageThreshold::New(); + + if (bbGetInputIn()!=NULL) + { + filter->SetInValue( bbGetInputInValue() ); + filter->SetOutValue( bbGetInputOutValue() ); + filter->SetInputData( bbGetInputIn() ); + filter->ThresholdBetween( bbGetInputLower(),bbGetInputUpper() ); + filter->Update(); + bbSetOutputOut( filter->GetOutput() ); + } else { + bbSetOutputOut( NULL ); + }// 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 ImageThreshold::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + filter=NULL; + bbSetInputIn(NULL); + bbSetInputLower(0); + bbSetInputUpper(10000); + bbSetInputInValue(255); + bbSetInputOutValue(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 ImageThreshold::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 ImageThreshold::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/bbcreaVtkImageThreshold.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h new file mode 100644 index 0000000..7a5f2f2 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImageThreshold.h @@ -0,0 +1,60 @@ +//===== +// 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 __bbcreaVtkImageThreshold_h_INCLUDED__ +#define __bbcreaVtkImageThreshold_h_INCLUDED__ + +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" +#include + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT ImageThreshold + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageThreshold,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(Lower,double); + BBTK_DECLARE_INPUT(Upper,double); + BBTK_DECLARE_INPUT(InValue,double); + BBTK_DECLARE_INPUT(OutValue,double); + BBTK_DECLARE_OUTPUT(Out,vtkImageData*); + BBTK_PROCESS(Process); + void Process(); + + vtkImageThreshold *filter; + +//===== +// 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(ImageThreshold,bbtk::AtomicBlackBox); + BBTK_NAME("ImageThreshold"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(ImageThreshold,In,"Input image",vtkImageData*,""); + BBTK_INPUT(ImageThreshold,Lower,"(default 0) Lower threshold",double,""); + BBTK_INPUT(ImageThreshold,Upper,"(default 10000) Upper threshold",double,""); + BBTK_INPUT(ImageThreshold,InValue,"(default 255) In value",double,""); + BBTK_INPUT(ImageThreshold,OutValue,"(default 0) Out Value",double,""); + BBTK_OUTPUT(ImageThreshold,Out,"Output image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageThreshold); +//===== +// 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 // __bbcreaVtkImageThreshold_h_INCLUDED__ + -- 2.45.1