2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbitkImageStatistics.h,v $
32 Date: $Date: 2013/03/27 $
33 Version: $Revision: 1.0 $
34 Modified by: Ricardo A Corredor (RaC)
35 =========================================================================*/
40 * \brief class ITKImageStatistics : generic ITKImage statistics
43 * \class bbtk::ITKImageStatistics
44 * \brief Generic ITKImage statictis
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)
51 #ifndef __bbitkImageStatistics_h_INCLUDED__
52 #define __bbitkImageStatistics_h_INCLUDED__
53 //#include "bbitk_EXPORT.h"
54 #include "bbtkAtomicBlackBox.h"
58 #include "bbitkImage.h"
60 #include <itkStatisticsImageFilter.h>
66 class /*bbitk_EXPORT*/ ImageStatistics
68 public bbtk::AtomicBlackBox
70 BBTK_BLACK_BOX_INTERFACE(ImageStatistics,bbtk::AtomicBlackBox);
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)
74 BBTK_DECLARE_INPUT(In,bbitk::anyImagePointer);
75 BBTK_DECLARE_OUTPUT(Min,double);
76 BBTK_DECLARE_OUTPUT(Max,double);
77 BBTK_DECLARE_OUTPUT(Mean,double);
78 BBTK_DECLARE_OUTPUT(StdDev,double);
79 BBTK_PROCESS(Process);
81 inline void Process();
82 template <class T> void ProcessTemplated();
84 // 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)
88 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageStatistics,bbtk::AtomicBlackBox);
89 BBTK_NAME("ImageStatistics");
90 BBTK_AUTHOR("Ricardo A Corredor");
91 BBTK_DESCRIPTION("Basic Image Statistics (minimim, maximum, mean, standard deviation)");
93 BBTK_INPUT(ImageStatistics,In,"Input image. Can be any itk::Image<T,D>*",bbitk::anyImagePointer,"");
94 BBTK_OUTPUT(ImageStatistics,Min,"Image minimum",double,"");
95 BBTK_OUTPUT(ImageStatistics,Max,"Image maximum",double,"");
96 BBTK_OUTPUT(ImageStatistics,Mean,"Image mean",double,"");
97 BBTK_OUTPUT(ImageStatistics,StdDev,"Image standard deviation",double,"");
98 BBTK_END_DESCRIBE_BLACK_BOX(ImageStatistics);
100 // 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)
104 //===================================================
105 void ImageStatistics::Process()
107 bbtk::TypeInfo t = bbGetInputIn().type();
108 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->ProcessTemplated);
110 //===================================================
113 //===================================================
114 template <class ImageType>
115 void ImageStatistics::ProcessTemplated()
117 bbtkDebugMessageInc("Core",9,"bbitk::ImageStatistics::Process<"<<bbtk::TypeName<ImageType>()<<">()"<<std::endl);
119 typedef itk::StatisticsImageFilter<ImageType> StatisticsImageFilterType;
120 typename StatisticsImageFilterType::Pointer statisticsImageFilter = StatisticsImageFilterType::New ();
123 ImageType* in = this->bbGetInputIn().get<ImageType*>();
125 statisticsImageFilter->SetInput(in);
126 statisticsImageFilter->Update();
128 std::cout << "Mean: " << statisticsImageFilter->GetMean() << std::endl;
129 std::cout << "Std.: " << statisticsImageFilter->GetSigma() << std::endl;
130 std::cout << "Min: " << statisticsImageFilter->GetMinimum() << std::endl;
131 std::cout << "Max: " << statisticsImageFilter->GetMaximum() << std::endl;
133 bbSetOutputMin((double)statisticsImageFilter->GetMinimum());
134 bbSetOutputMax((double)statisticsImageFilter->GetMaximum());
135 bbSetOutputMean((double)statisticsImageFilter->GetMean());
136 bbSetOutputStdDev((double)statisticsImageFilter->GetSigma());
138 bbtkDebugDecTab("Core",9);
140 //===================================================
143 // EO namespace bbitk
145 #endif // __bbitkImageStatistics_h_INCLUDED__