00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <iostream>
00026
00027 #include "models/color/thresholds.h"
00028
00029 using namespace std;
00030
00031 namespace firevision {
00032 #if 0
00033 }
00034 #endif
00035
00036
00037
00038
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 (
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
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 }