]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuContourStatistics.cxx
#2647 creaMaracasVisu Feature New Normal - Merge creaButtonContainer BRANCH
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuContourStatistics.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "bbmaracasvisuContourStatistics.h"
27 #include "bbcreaMaracasVisuPackage.h"
28 #include <math.h>
29 namespace bbcreaMaracasVisu
30 {
31
32 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourStatistics)
33 BBTK_BLACK_BOX_IMPLEMENTATION(ContourStatistics,bbtk::AtomicBlackBox);
34
35 //------------------------------------------------------------
36 void ContourStatistics::Process()
37 {
38
39           double max=0,min=0;
40           double average=0,standardeviation=0;
41           double acum=0;
42           double ng;
43           int size=0;
44           if (bbGetInputLstValue()!=NULL)
45           {
46                 size=bbGetInputLstValue()->size();
47                 if (size>0){
48                max=(*bbGetInputLstValue())[0];
49                    min=(*bbGetInputLstValue())[0];
50      // Average
51                         int i;
52                         for ( i=0; i<size; i++ )
53                         {
54                                 ng=(*bbGetInputLstValue())[i];
55                                 acum = acum + ng;
56                                 if (max<ng) max=ng;             // Max
57                                 if (min>ng) min=ng;     // Min
58                         }
59                         average = acum / size;
60
61           // Standar Deviation
62                         acum=0;
63                         double tmp;
64                         for ( i=0; i<size; i++ )
65                         {
66                 tmp = (*bbGetInputLstValue())[i] - average;
67                                 acum = acum + tmp*tmp;
68                         }
69                         standardeviation = sqrt(acum/size);
70
71                 }
72           }
73
74           // OUTPUT
75       bbSetOutputMax( max );
76       bbSetOutputnPoints( size );
77       bbSetOutputMin( min );
78       bbSetOutputAverage( average );
79       bbSetOutputStandarDeviation( standardeviation );
80 }
81
82 //------------------------------------------------------------
83 void ContourStatistics::bbUserSetDefaultValues()
84 {
85       bbSetInputLstValue(NULL);
86 }
87
88         
89         //-----------------------------------------------------------------     
90         void ContourStatistics::bbUserInitializeProcessing()
91         {
92         }
93         
94         //-----------------------------------------------------------------     
95         void ContourStatistics::bbUserFinalizeProcessing()
96         {
97         }
98         
99         //-----------------------------------------------------------------     
100         
101
102 }
103 // EO namespace bbcreaMaracasVisu
104
105