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 <fvmodels/color/thresholds.h>
26
27#include <iostream>
28
29using namespace std;
30
31namespace firevision {
32
33/** @class ColorModelThresholds <fvmodels/color/thresholds.h>
34 * Really simple thresholds-based model with some hard-coded thresholds. Was
35 * just for initial development of color models.
36 */
37
38color_t
39ColorModelThresholds::determine(unsigned int y, unsigned int u, unsigned int v) const
40{
41 if (y >= THRESHOLD_WHITE_Y_LOW) {
42 return C_WHITE;
43 }
44 if (u <= THRESHOLD_GREEN_U_HIGH && v <= THRESHOLD_GREEN_V_HIGH) {
45 return C_GREEN;
46 } else if (/*THRESHOLD_ORANGE_U_LOW <= u &&*/
47 u <= THRESHOLD_ORANGE_U_HIGH && v >= THRESHOLD_ORANGE_V_LOW) {
48 return C_ORANGE;
49 } else if (u >= THRESHOLD_BLUE_U_LOW && v <= THRESHOLD_BLUE_V_HIGH) {
50 return C_BLUE;
51 } else if (u <= THRESHOLD_YELLOW_U_HIGH && v >= THRESHOLD_YELLOW_V_LOW) {
52 return C_YELLOW;
53 } else if (u >= THRESHOLD_MAGENTA_U_LOW && v >= THRESHOLD_MAGENTA_V_LOW) {
54 return C_MAGENTA;
55 } else if (THRESHOLD_CYAN_U_LOW <= u && u <= THRESHOLD_CYAN_U_HIGH
56 && v <= THRESHOLD_CYAN_V_HIGH) {
57 return C_CYAN;
58 } else {
59 return C_OTHER;
60 }
61}
62
63const char *
65{
66 return "ColorModelThresholds";
67}
68
69/** Print the thresholds to stdout.
70 */
71void
73{
74 cout << "ColorModelThresholds" << endl
75 << "==========================================================" << endl
76 << "Orange: u_low=" << THRESHOLD_ORANGE_U_LOW << " u_high=" << THRESHOLD_ORANGE_U_HIGH
77 << " v_low=" << THRESHOLD_ORANGE_V_LOW << endl
78 << "Yellow: u_high=" << THRESHOLD_YELLOW_U_HIGH << " v_low=" << THRESHOLD_YELLOW_V_LOW
79 << endl;
80}
81
82} // end namespace firevision
const char * get_name()
Get name of color model.
Definition: thresholds.cpp:64
void print_thresholds()
Print the thresholds to stdout.
Definition: thresholds.cpp:72
color_t determine(unsigned int y, unsigned int u, unsigned int v) const
Determine classification of YUV pixel.
Definition: thresholds.cpp:39