Fawkes API  Fawkes Development Version
thresholds.cpp
1 
2 /***************************************************************************
3  * thresholds.cpp - Implementation of a thresholds color model
4  *
5  * Created: Wed May 18 13:59:18 2005
6  * Copyright 2005 Tim Niemueller [www.niemueller.de]
7  * Matrin Heracles <martin.heracles@rwth-aachen.de>
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #include <iostream>
26 
27 #include <fvmodels/color/thresholds.h>
28 
29 using namespace std;
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 /** @class ColorModelThresholds <fvmodels/color/thresholds.h>
37  * Really simple thresholds-based model with some hard-coded thresholds. Was
38  * just for initial development of color models.
39  */
40 
41 color_t
42 ColorModelThresholds::determine(unsigned int y,
43  unsigned int u,
44  unsigned int v) const
45 {
46  if ( y >= THRESHOLD_WHITE_Y_LOW) {
47  return C_WHITE;
48  }
49  if ( u <= THRESHOLD_GREEN_U_HIGH &&
50  v <= THRESHOLD_GREEN_V_HIGH) {
51  return C_GREEN;
52  }
53  else if (/*THRESHOLD_ORANGE_U_LOW <= u &&*/
54  u <= THRESHOLD_ORANGE_U_HIGH &&
55  v >= THRESHOLD_ORANGE_V_LOW) {
56  return C_ORANGE;
57  }
58  else if (u >= THRESHOLD_BLUE_U_LOW &&
59  v <= THRESHOLD_BLUE_V_HIGH) {
60  return C_BLUE;
61  }
62  else if (u <= THRESHOLD_YELLOW_U_HIGH &&
63  v >= THRESHOLD_YELLOW_V_LOW) {
64  return C_YELLOW;
65  }
66  else if (u >= THRESHOLD_MAGENTA_U_LOW &&
67  v >= THRESHOLD_MAGENTA_V_LOW) {
68  return C_MAGENTA;
69  }
70  else if (THRESHOLD_CYAN_U_LOW <= u &&
71  u <= THRESHOLD_CYAN_U_HIGH &&
72  v <= THRESHOLD_CYAN_V_HIGH) {
73  return C_CYAN;
74  }
75  else {
76  return C_OTHER;
77  }
78 }
79 
80 const char *
81 ColorModelThresholds::get_name()
82 {
83  return "ColorModelThresholds";
84 }
85 
86 
87 /** Print the thresholds to stdout.
88  */
89 void
90 ColorModelThresholds::print_thresholds()
91 {
92  cout << "ColorModelThresholds" << endl
93  << "==========================================================" << endl
94  << "Orange: u_low=" << THRESHOLD_ORANGE_U_LOW
95  << " u_high=" << THRESHOLD_ORANGE_U_HIGH
96  << " v_low=" << THRESHOLD_ORANGE_V_LOW
97  << endl
98  << "Yellow: u_high=" << THRESHOLD_YELLOW_U_HIGH
99  << " v_low=" << THRESHOLD_YELLOW_V_LOW
100  << endl;
101 }
102 
103 } // end namespace firevision
STL namespace.