Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * thresholds.cpp - Implementation of a thresholds color model 00004 * 00005 * Created: Wed May 18 13:59:18 2005 00006 * Copyright 2005 Tim Niemueller [www.niemueller.de] 00007 * Matrin Heracles <martin.heracles@rwth-aachen.de> 00008 * 00009 ****************************************************************************/ 00010 00011 /* This program is free software; you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation; either version 2 of the License, or 00014 * (at your option) any later version. A runtime exception applies to 00015 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU Library General Public License for more details. 00021 * 00022 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00023 */ 00024 00025 #include <iostream> 00026 00027 #include "models/color/thresholds.h" 00028 00029 using namespace std; 00030 00031 namespace firevision { 00032 #if 0 /* just to make Emacs auto-indent happy */ 00033 } 00034 #endif 00035 00036 /** @class ColorModelThresholds <models/color/thresholds.h> 00037 * Really simple thresholds-based model with some hard-coded thresholds. Was 00038 * just for initial development of color models. 00039 */ 00040 00041 color_t 00042 ColorModelThresholds::determine(unsigned int y, 00043 unsigned int u, 00044 unsigned int v) const 00045 { 00046 if ( y >= THRESHOLD_WHITE_Y_LOW) { 00047 return C_WHITE; 00048 } 00049 if ( u <= THRESHOLD_GREEN_U_HIGH && 00050 v <= THRESHOLD_GREEN_V_HIGH) { 00051 return C_GREEN; 00052 } 00053 else if (/*THRESHOLD_ORANGE_U_LOW <= u &&*/ 00054 u <= THRESHOLD_ORANGE_U_HIGH && 00055 v >= THRESHOLD_ORANGE_V_LOW) { 00056 return C_ORANGE; 00057 } 00058 else if (u >= THRESHOLD_BLUE_U_LOW && 00059 v <= THRESHOLD_BLUE_V_HIGH) { 00060 return C_BLUE; 00061 } 00062 else if (u <= THRESHOLD_YELLOW_U_HIGH && 00063 v >= THRESHOLD_YELLOW_V_LOW) { 00064 return C_YELLOW; 00065 } 00066 else if (u >= THRESHOLD_MAGENTA_U_LOW && 00067 v >= THRESHOLD_MAGENTA_V_LOW) { 00068 return C_MAGENTA; 00069 } 00070 else if (THRESHOLD_CYAN_U_LOW <= u && 00071 u <= THRESHOLD_CYAN_U_HIGH && 00072 v <= THRESHOLD_CYAN_V_HIGH) { 00073 return C_CYAN; 00074 } 00075 else { 00076 return C_OTHER; 00077 } 00078 } 00079 00080 const char * 00081 ColorModelThresholds::get_name() 00082 { 00083 return "ColorModelThresholds"; 00084 } 00085 00086 00087 /** Print the thresholds to stdout. 00088 */ 00089 void 00090 ColorModelThresholds::print_thresholds() 00091 { 00092 cout << "ColorModelThresholds" << endl 00093 << "==========================================================" << endl 00094 << "Orange: u_low=" << THRESHOLD_ORANGE_U_LOW 00095 << " u_high=" << THRESHOLD_ORANGE_U_HIGH 00096 << " v_low=" << THRESHOLD_ORANGE_V_LOW 00097 << endl 00098 << "Yellow: u_high=" << THRESHOLD_YELLOW_U_HIGH 00099 << " v_low=" << THRESHOLD_YELLOW_V_LOW 00100 << endl; 00101 } 00102 00103 } // end namespace firevision