summaryrefslogtreecommitdiff
path: root/2004/i/nono/src/ovision/segmNN.h
blob: 102eaf2bb57908337fb169cc50d9e85eb9ed4999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// nono2 - programme du robot 2005 
// 
// Copyright (C) 2004 Olivier Gaillard
//
// Robot APB Team/Efrei 2004.
//        Web: http://assos.efrei.fr/robot/
//      Email: robot AT efrei DOT fr
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#ifndef segmNN_h
#define segmNN_h

#include "img.h"
#include "oconfig.h"

// Constantes 
#define MIN 0
#define MAX 1

#define UNDEFINED 254

/// Constantes pour la creation du NN
#define LOAD_FROM_FILE  1
#define GENERATE 	0

/// Segmente l'image et cree un tableau contenant des valeurs segmentees, creation du reseau de neurones et apprentissage 
class SegmNN
{
  public:
    /// Constructeur
    SegmNN (Img *img);

    /// Destructeur
    virtual ~SegmNN (void);
    
    // tableau avec couleurs segment�es
    unsigned char *tabSegm;
    
    // index des couleurs pour melanger (merge) les couleurs
    int *index; 

    // tableau de poids du NN
    unsigned char *node; 


    /// Affiche la valeur des poids du NN
    void ShowNodes(); 

    /// Cree le NN
    void BuildNN (int nbOutput, int loadFromFile = true); 

    /// Segmentation de l'image
    void Segm ();

    /// Segmentation de l'image permettant d'isoler une couleur
    void Segm (int numColor); 

    /// Renvoie le code la couleur segmentee
    unsigned char FindColorNN(unsigned char *x, bool testOutputMax = false);

    /// Donne la couleur � partir du tableau
    virtual unsigned char GiveColor (unsigned char *x, bool testOutputMax = false, bool indexProcess = false) = 0;

  protected:
    // Classe image
    Img *img; 

    // Classe config
    OConfig *oconfig;

    // nb de couleurs a differencier
    int nbOutput; 

    /// Renvoie la sortie ayant le plus haut niveau
    int WinnerOutput (unsigned char *x);

};

#endif // segmNN_h