From 89e356bbe8118769dbf588508695f1496506ae43 Mon Sep 17 00:00:00 2001 From: Alfredo Morales Date: Mon, 12 Mar 2012 08:48:03 +0000 Subject: [PATCH] Black box that generates a grid over an image in order to visualize the deformation field after a transformation. --- .../bbPackRecalageGridOnImageGenerator.cxx | 72 +++++++++++++++++++ .../src/bbPackRecalageGridOnImageGenerator.h | 67 +++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 PackRecalage/src/bbPackRecalageGridOnImageGenerator.cxx create mode 100644 PackRecalage/src/bbPackRecalageGridOnImageGenerator.h diff --git a/PackRecalage/src/bbPackRecalageGridOnImageGenerator.cxx b/PackRecalage/src/bbPackRecalageGridOnImageGenerator.cxx new file mode 100644 index 0000000..23cb540 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageGridOnImageGenerator.cxx @@ -0,0 +1,72 @@ +//===== +// 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 "bbPackRecalageGridOnImageGenerator.h" +#include "bbPackRecalagePackage.h" +namespace bbPackRecalage +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(PackRecalage,GridOnImageGenerator) +BBTK_BLACK_BOX_IMPLEMENTATION(GridOnImageGenerator,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 GridOnImageGenerator::Process() +{ + std::cout << "GridOnImageGenerator" << std::endl; + //Variables + vtkImageData* inImage = NULL; + vtkImageData* outputImage = NULL; + double gridSpcX = 0, gridSpcY = 0, gridSpcZ = 0; + + //Get inputs + inImage = bbGetInputIn(); + gridSpcX = bbGetInputGridSpcX(); + gridSpcY = bbGetInputGridSpcY(); + gridSpcZ = bbGetInputGridSpcZ(); + + //Grid on image generator + gridOnImageGenerator = new MyGridOnImageGenerator(inImage, gridSpcX, gridSpcY, gridSpcZ); + + outputImage = gridOnImageGenerator->getGridOnImage(); + bbSetOutputOut( outputImage ); + std::cout << "GridOnImageGenerator ... OK" << std::endl; + +} +//===== +// 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 GridOnImageGenerator::bbUserSetDefaultValues() +{ + bbSetInputIn(NULL); + bbSetInputGridSpcX(0); + bbSetInputGridSpcY(0); + bbSetInputGridSpcZ(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 GridOnImageGenerator::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 GridOnImageGenerator::bbUserFinalizeProcessing() +{ + + if(gridOnImageGenerator != NULL) + delete gridOnImageGenerator; + +} +} +// EO namespace bbPackRecalage + + diff --git a/PackRecalage/src/bbPackRecalageGridOnImageGenerator.h b/PackRecalage/src/bbPackRecalageGridOnImageGenerator.h new file mode 100644 index 0000000..254c6b3 --- /dev/null +++ b/PackRecalage/src/bbPackRecalageGridOnImageGenerator.h @@ -0,0 +1,67 @@ +//===== +// 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 __bbPackRecalageGridOnImageGenerator_h_INCLUDED__ +#define __bbPackRecalageGridOnImageGenerator_h_INCLUDED__ +#include "bbPackRecalage_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +//VTK +#include "vtkImageData.h" + +//OWN +#include "MyGridOnImageGenerator.h" + +namespace bbPackRecalage +{ + +class bbPackRecalage_EXPORT GridOnImageGenerator + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(GridOnImageGenerator,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(GridSpcX,double); + BBTK_DECLARE_INPUT(GridSpcY,double); + BBTK_DECLARE_INPUT(GridSpcZ,double); + + 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) +//===== + +private: + + //Grid on image generator attribute + MyGridOnImageGenerator* gridOnImageGenerator; + +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(GridOnImageGenerator,bbtk::AtomicBlackBox); +BBTK_NAME("GridOnImageGenerator"); +BBTK_AUTHOR("Alfredo Morales Pinzon, morales@creatis.insa-lyon.fr, write me if you have questions :) N'hésitez pas"); +BBTK_DESCRIPTION("Box that creates an grid over an image. This is usually used to visualized the deformation that takes place over an image after a transformation, specially when non-rigid registration is applied. In order to create the grid the user must specify the spacing in each direction using the image coordinates, for example in milimeters. The final image contrast is based on the maximum and minimum values over the entire image."); +BBTK_CATEGORY("Registration"); + +BBTK_INPUT(GridOnImageGenerator,In,"Input image",vtkImageData*,""); +BBTK_INPUT(GridOnImageGenerator,GridSpcX,"Grid spacing in X",double,""); +BBTK_INPUT(GridOnImageGenerator,GridSpcY,"Grid spacing in Y",double,""); +BBTK_INPUT(GridOnImageGenerator,GridSpcZ,"Grid spacing in Z",double,""); + +BBTK_OUTPUT(GridOnImageGenerator,Out,"Output image",vtkImageData*,""); +BBTK_END_DESCRIBE_BLACK_BOX(GridOnImageGenerator); +//===== +// 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 bbPackRecalage + +#endif // __bbPackRecalageGridOnImageGenerator_h_INCLUDED__ + -- 2.45.0