From 7bfc4edc9a0768d45faee896e9e95dad33147626 Mon Sep 17 00:00:00 2001 From: ctorres Date: Wed, 20 Nov 2013 15:28:31 +0100 Subject: [PATCH] New functionality, obtain an 3D image vector from an image. --- .../src/bbcreaVtkImage3DVector.cxx | 62 ++++++++++ .../src/bbcreaVtkImage3DVector.cxx~ | 62 ++++++++++ bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h | 50 ++++++++ .../src/bbcreaVtkImage3DVector.h~ | 49 ++++++++ lib/creaVtk/creaVtkIma3DVector.cpp | 110 ++++++++++++++++++ lib/creaVtk/creaVtkIma3DVector.cpp~ | 47 ++++++++ lib/creaVtk/creaVtkIma3DVector.h | 69 +++++++++++ lib/creaVtk/creaVtkIma3DVector.h~ | 64 ++++++++++ 8 files changed, 513 insertions(+) create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx~ create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h create mode 100644 bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h~ create mode 100644 lib/creaVtk/creaVtkIma3DVector.cpp create mode 100644 lib/creaVtk/creaVtkIma3DVector.cpp~ create mode 100644 lib/creaVtk/creaVtkIma3DVector.h create mode 100644 lib/creaVtk/creaVtkIma3DVector.h~ diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx new file mode 100644 index 0000000..1d8d2d4 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx @@ -0,0 +1,62 @@ +//===== +// 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 "bbcreaVtkImage3DVector.h" +#include "bbcreaVtkPackage.h" +#include "creaVtkIma3DVector.h" +#include "vtkImageData.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Image3DVector) +BBTK_BLACK_BOX_IMPLEMENTATION(Image3DVector,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 Image3DVector::Process() +{ + + creaVtkIma3DVector cvtkc; + bbSetOutputOut( cvtkc.Ima3DVectorM ((unsigned int)bbGetInputNbImagesPerRow(), (unsigned int)bbGetInputNbImagesInMosaic(), bbGetInputIn() ) ); + +} +//===== +// 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 Image3DVector::bbUserSetDefaultValues() +{ + + bbSetInputNbImagesPerRow(0); + bbSetInputNbImagesInMosaic(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 Image3DVector::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 Image3DVector::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/bbcreaVtkImage3DVector.cxx~ b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx~ new file mode 100644 index 0000000..8be9357 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.cxx~ @@ -0,0 +1,62 @@ +//===== +// 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 "bbcreaVtkImage3DVector.h" +#include "bbcreaVtkPackage.h" +#include "creaVtkClass.h" +#include "vtkImageData.h" + +namespace bbcreaVtk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Image3DVector) +BBTK_BLACK_BOX_IMPLEMENTATION(Image3DVector,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 Image3DVector::Process() +{ + + creaVtkClass cvtkc; + bbSetOutputOut( cvtkc.Ima3DVectorM ((unsigned int)bbGetInputNbImagesPerRow(), (unsigned int)bbGetInputNbImagesInMosaic(), bbGetInputIn() ) ); + +} +//===== +// 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 Image3DVector::bbUserSetDefaultValues() +{ + + bbSetInputNbImagesPerRow(0); + bbSetInputNbImagesInMosaic(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 Image3DVector::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 Image3DVector::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/bbcreaVtkImage3DVector.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h new file mode 100644 index 0000000..8cba6c0 --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h @@ -0,0 +1,50 @@ +//===== +// 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 __bbcreaVtkImage3DVector_h_INCLUDED__ +#define __bbcreaVtkImage3DVector_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "vtkImageData.h" +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT Image3DVector + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(Image3DVector,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,std::vector); + BBTK_DECLARE_INPUT (NbImagesPerRow,int); + BBTK_DECLARE_INPUT (NbImagesInMosaic,int); + BBTK_DECLARE_OUTPUT(Out,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(Image3DVector,bbtk::AtomicBlackBox); +BBTK_NAME("Image3DVector"); +BBTK_AUTHOR("Carlos torres"); +BBTK_DESCRIPTION("carlos.torres@insa-lyon.fr -"); +BBTK_CATEGORY("empty"); +BBTK_INPUT(Image3DVector,In,"2D image list",std::vector,""); +BBTK_INPUT(Image3DVector,NbImagesPerRow,"Nb of Images Per Row ",int,""); +BBTK_INPUT(Image3DVector,NbImagesInMosaic,"Nb of Images In Mosaic ",int,""); +BBTK_OUTPUT(Image3DVector,Out,"3D image Vector",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(Image3DVector); +//===== +// 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 // __bbcreaVtkImage3DVector_h_INCLUDED__ + diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h~ b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h~ new file mode 100644 index 0000000..e3fad8c --- /dev/null +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkImage3DVector.h~ @@ -0,0 +1,49 @@ +//===== +// 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 __bbcreaVtkImage3DVector_h_INCLUDED__ +#define __bbcreaVtkImage3DVector_h_INCLUDED__ +#include "bbcreaVtk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +namespace bbcreaVtk +{ + +class bbcreaVtk_EXPORT Image3DVector + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(Image3DVector,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,std::vector); + BBTK_DECLARE_INPUT (NbImagesPerRow,int); + BBTK_DECLARE_INPUT (NbImagesInMosaic,int); + BBTK_DECLARE_OUTPUT(Out,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(Image3DVector,bbtk::AtomicBlackBox); +BBTK_NAME("Image3DVector"); +BBTK_AUTHOR("Carlos torres"); +BBTK_DESCRIPTION("carlos.torres@insa-lyon.fr -"); +BBTK_CATEGORY("empty"); +BBTK_INPUT(Image3DVector,In,"2D image list",std::vector,""); +BBTK_INPUT(Image3DVector,NbImagesPerRow,"Nb of Images Per Row ",int,""); +BBTK_INPUT(Image3DVector,NbImagesInMosaic,"Nb of Images In Mosaic ",int,""); +BBTK_OUTPUT(Image3DVector,Out,"3D image Vector",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(Image3DVector); +//===== +// 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 // __bbcreaVtkImage3DVector_h_INCLUDED__ + diff --git a/lib/creaVtk/creaVtkIma3DVector.cpp b/lib/creaVtk/creaVtkIma3DVector.cpp new file mode 100644 index 0000000..339e1cc --- /dev/null +++ b/lib/creaVtk/creaVtkIma3DVector.cpp @@ -0,0 +1,110 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sante) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ + +#include "creaVtkIma3DVector.h" + +creaVtkIma3DVector::creaVtkIma3DVector() +{ +} + +creaVtkIma3DVector::~creaVtkIma3DVector() +{ +} + +std::vector creaVtkIma3DVector::Ima3DVectorM (int NbImagesPerRow, int NbImagesInMosaic, std::vector bbGetInputIn) +{ + int nbImagesPerRow = NbImagesPerRow; + int nbImagesInMosaic = NbImagesInMosaic; + + if (nbImagesPerRow == 0 || nbImagesInMosaic == 0) { + std::cout << "Not possible" << std::endl; + } + + std::vector imageIn = bbGetInputIn; + + std::vector mImageOut; + for (int i = 0 ; i < (unsigned int)imageIn.size() ; i++) { + mImageOut.push_back( unMosaic(imageIn[i], NbImagesPerRow, NbImagesInMosaic) ); + } + + return mImageOut; +} + +vtkImageData * creaVtkIma3DVector::unMosaic(vtkImageData *imageIn, int nbImagesPerRow, int numberOfImagesInMosaic) +{ + int inputdims[3]; + int outputdims[3]; + imageIn->GetDimensions (inputdims); + unsigned short *input = (unsigned short *)(imageIn->GetScalarPointer()); + imageIn->Update(); + + unsigned int div = (unsigned int)ceil(sqrt( (double)numberOfImagesInMosaic ) ); + outputdims[0] = inputdims[0] / div; + outputdims[1] = inputdims[1] / div; + outputdims[2] = numberOfImagesInMosaic; + + vtkImageData *vtkImageOut; + vtkImageOut = vtkImageData::New(); + vtkImageOut->SetDimensions( outputdims ); + vtkImageOut->SetExtent(0,outputdims[0]-1,0,outputdims[1]-1,0,outputdims[2]-1); + vtkImageOut->SetWholeExtent(0,outputdims[0]-1,0,outputdims[1]-1,0,outputdims[2]-1); + vtkImageOut->SetNumberOfScalarComponents(1); +//vtkImageOut->SetSpacing( blabla ); + vtkImageOut->SetScalarType( VTK_UNSIGNED_SHORT ); + vtkImageOut->AllocateScalars(); + vtkImageOut->Update(); + + unsigned short *output =(unsigned short *)(vtkImageOut->GetScalarPointer()); + + unsigned short *dest = output; + int dimXImageElem = outputdims[0]; + int dimYImageElem = outputdims[1]; + int lgrImage = dimXImageElem*dimYImageElem; + int debImage; + for (int i=0; i +#include "iostream" +#include "vtkImageData.h" + +//--------------------------------------------- +// Class Name: creaVtkIma3DVector +// [classdescription] +//--------------------------------------------- + +class creaVtkIma3DVector +{ + +//--------------------------------------------- +//Methods and attributes exposed to other classes +//--------------------------------------------- +public : + creaVtkIma3DVector(); + ~creaVtkIma3DVector(); + std::vector Ima3DVectorM (int NbImagesPerRow, int NbImagesInMosaic, std::vector bbGetInputIn); + vtkImageData * unMosaic(vtkImageData *imageIn, int nbImagesPerRow, int numberOfImagesInMosaic); + +//--Method template---------------------------- +// void FunctionName(int& parameterA); + + +//--------------------------------------------- +//Methods and attributes exposed only to classes +//that are derived from this class +//--------------------------------------------- +protected: + +//--------------------------------------------- +//Methods and attributes only visible by this class +//--------------------------------------------- +private: + +}; + +//-end of _CREAVTKIMA3DVECTOR_H_------------------------------------------------------ +#endif diff --git a/lib/creaVtk/creaVtkIma3DVector.h~ b/lib/creaVtk/creaVtkIma3DVector.h~ new file mode 100644 index 0000000..f3692a1 --- /dev/null +++ b/lib/creaVtk/creaVtkIma3DVector.h~ @@ -0,0 +1,64 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Sante) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ + +#ifndef _CREAVTKIMA3DVECTOR_H_ +#define _CREAVTKIMA3DVECTOR_H_ + +//--------------------------------------------- +// Class Name: creaVtkIma3DVector +// [classdescription] +//--------------------------------------------- + +class creaVtkIma3DVector +{ + +//--------------------------------------------- +//Methods and attributes exposed to other classes +//--------------------------------------------- +public : + creaVtkIma3DVector(); + ~creaVtkIma3DVector(); + +//--Method template---------------------------- +// void FunctionName(int& parameterA); + + +//--------------------------------------------- +//Methods and attributes exposed only to classes +//that are derived from this class +//--------------------------------------------- +protected: + +//--------------------------------------------- +//Methods and attributes only visible by this class +//--------------------------------------------- +private: + +}; + +//-end of _CREAVTKIMA3DVECTOR_H_------------------------------------------------------ +#endif -- 2.47.1