From 66abc4988b46815575ccc40e0929c8393cdeab2d Mon Sep 17 00:00:00 2001 From: Ricardo A Corredor Date: Wed, 27 Mar 2013 19:16:16 +0100 Subject: [PATCH] Issue #1959 - New black box to calculate the minimum, maximum, std dev and mean intensity of an image. --- packages/itk/src/bbitkImageStatistics.cxx | 95 ++++++++++++++ packages/itk/src/bbitkImageStatistics.h | 147 ++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 packages/itk/src/bbitkImageStatistics.cxx create mode 100644 packages/itk/src/bbitkImageStatistics.h diff --git a/packages/itk/src/bbitkImageStatistics.cxx b/packages/itk/src/bbitkImageStatistics.cxx new file mode 100644 index 0000000..3ed5384 --- /dev/null +++ b/packages/itk/src/bbitkImageStatistics.cxx @@ -0,0 +1,95 @@ + +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # 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. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbitkImageStatistics.h,v $ + Language: C++ + Date: $Date: 2013/03/27 $ + Version: $Revision: 1.0 $ + Modified by: Ricardo A Corredor (RaC) +=========================================================================*/ + + +/** + * \file + * \brief class ITKImageStatistics : generic ITKImage statistics + */ +/** + * \class bbtk::ITKImageStatistics + * \brief Generic ITKImage statictis + */ + +#ifdef _USE_ITK_ +//===== +// 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 "bbitkImageStatistics.h" +#include "bbitkPackage.h" +namespace bbitk +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageStatistics) +BBTK_BLACK_BOX_IMPLEMENTATION(ImageStatistics,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) +//===== + +//===== +// 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 ImageStatistics::bbUserSetDefaultValues() +{ + bbSetOutputMin(0); + bbSetOutputMax(0); + bbSetOutputMean(0); + bbSetOutputStdDev(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 ImageStatistics::bbUserInitializeProcessing() +{ + + + + +} +//===== +// 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 ImageStatistics::bbUserFinalizeProcessing() +{ + +} +} +// EO namespace bbitk +#endif + diff --git a/packages/itk/src/bbitkImageStatistics.h b/packages/itk/src/bbitkImageStatistics.h new file mode 100644 index 0000000..9fa0049 --- /dev/null +++ b/packages/itk/src/bbitkImageStatistics.h @@ -0,0 +1,147 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # 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. + # ------------------------------------------------------------------------ */ + + +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbitkImageStatistics.h,v $ + Language: C++ + Date: $Date: 2013/03/27 $ + Version: $Revision: 1.0 $ + Modified by: Ricardo A Corredor (RaC) +=========================================================================*/ + + +/** + * \file + * \brief class ITKImageStatistics : generic ITKImage statistics + */ +/** + * \class bbtk::ITKImageStatistics + * \brief Generic ITKImage statictis + */ + +#ifdef _USE_ITK_ +//===== +// 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 __bbitkImageStatistics_h_INCLUDED__ +#define __bbitkImageStatistics_h_INCLUDED__ +//#include "bbitk_EXPORT.h" +#include "bbtkAtomicBlackBox.h" + +#include "iostream" + +#include "bbitkImage.h" + +#include + + +namespace bbitk +{ + +class /*bbitk_EXPORT*/ ImageStatistics + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(ImageStatistics,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,bbitk::anyImagePointer); + BBTK_DECLARE_OUTPUT(Min,double); + BBTK_DECLARE_OUTPUT(Max,double); + BBTK_DECLARE_OUTPUT(Mean,double); + BBTK_DECLARE_OUTPUT(StdDev,double); + BBTK_PROCESS(Process); +private: + inline void Process(); + template void ProcessTemplated(); +//===== +// 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(ImageStatistics,bbtk::AtomicBlackBox); +BBTK_NAME("ImageStatistics"); +BBTK_AUTHOR("Ricardo A Corredor"); +BBTK_DESCRIPTION("Basic Image Statistics (minimim, maximum, mean, standard deviation)"); +BBTK_CATEGORY(""); +BBTK_INPUT(ImageStatistics,In,"Input image. Can be any itk::Image*",bbitk::anyImagePointer,""); +BBTK_OUTPUT(ImageStatistics,Min,"Image minimum",double,""); +BBTK_OUTPUT(ImageStatistics,Max,"Image maximum",double,""); +BBTK_OUTPUT(ImageStatistics,Mean,"Image mean",double,""); +BBTK_OUTPUT(ImageStatistics,StdDev,"Image standard deviation",double,""); +BBTK_END_DESCRIBE_BLACK_BOX(ImageStatistics); +//===== +// 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 ImageStatistics::Process() +{ + bbtk::TypeInfo t = bbGetInputIn().type(); + BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->ProcessTemplated); +} +//=================================================== + + +//=================================================== +template +void ImageStatistics::ProcessTemplated() +{ + bbtkDebugMessageInc("Core",9,"bbitk::ImageStatistics::Process<"<()<<">()"< StatisticsImageFilterType; + typename StatisticsImageFilterType::Pointer statisticsImageFilter = StatisticsImageFilterType::New (); + + // Input + ImageType* in = this->bbGetInputIn().get(); + + statisticsImageFilter->SetInput(in); + statisticsImageFilter->Update(); + + std::cout << "Mean: " << statisticsImageFilter->GetMean() << std::endl; + std::cout << "Std.: " << statisticsImageFilter->GetSigma() << std::endl; + std::cout << "Min: " << statisticsImageFilter->GetMinimum() << std::endl; + std::cout << "Max: " << statisticsImageFilter->GetMaximum() << std::endl; + + bbSetOutputMin((double)statisticsImageFilter->GetMinimum()); + bbSetOutputMax((double)statisticsImageFilter->GetMaximum()); + bbSetOutputMean((double)statisticsImageFilter->GetMean()); + bbSetOutputStdDev((double)statisticsImageFilter->GetSigma()); + + bbtkDebugDecTab("Core",9); +} +//=================================================== + +} +// EO namespace bbitk + +#endif // __bbitkImageStatistics_h_INCLUDED__ + +#endif // _USE_ITK_ -- 2.45.0