latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*-------------------------------------------------------------------- 00025 * project ....: LTI-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiHmmTrellisDiagram.h 00027 * authors ....: Suat Akyol 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 16.5.2002 00030 * revisions ..: $Id: ltiHmmTrellisDiagram.h,v 1.8 2006/02/08 11:16:50 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_HMM_TRELLIS_DIAGRAM_H_ 00034 #define _LTI_HMM_TRELLIS_DIAGRAM_H_ 00035 00036 // include only those files which are needed in this header!! 00037 00038 #include "ltiDraw.h" 00039 #include "ltiHiddenMarkovModel.h" 00040 #include "ltiHmmViterbiPathSearch.h" 00041 // include to parent class: 00042 #include "ltiFunctor.h" 00043 00044 namespace lti { 00045 // comment your class 00046 /** 00047 * Draws the trellis diagram for visualizing the viterbi path selection 00048 * given by lti::hmmViterbiPathSearch for a lti::hiddenMarkovModel! 00049 */ 00050 class hmmTrellisDiagram : public functor { 00051 public: 00052 /** 00053 * the parameters for the class hmmTrellisDiagram 00054 */ 00055 class parameters : public functor::parameters { 00056 public: 00057 /** 00058 * default constructor 00059 */ 00060 parameters(); 00061 00062 /** 00063 * copy constructor 00064 * @param other the parameters object to be copied 00065 */ 00066 parameters(const parameters& other); 00067 00068 /** 00069 * destructor 00070 */ 00071 ~parameters(); 00072 00073 /** 00074 * returns name of this type 00075 */ 00076 const char* getTypeName() const; 00077 00078 /** 00079 * copy the contents of a parameters object 00080 * @param other the parameters object to be copied 00081 * @return a reference to this parameters object 00082 */ 00083 parameters& copy(const parameters& other); 00084 00085 /** 00086 * copy the contents of a parameters object 00087 * @param other the parameters object to be copied 00088 * @return a reference to this parameters object 00089 */ 00090 parameters& operator=(const parameters& other); 00091 00092 00093 /** 00094 * returns a pointer to a clone of the parameters 00095 */ 00096 virtual functor::parameters* clone() const; 00097 00098 /** 00099 * write the parameters in the given ioHandler 00100 * @param handler the ioHandler to be used 00101 * @param complete if true (the default) the enclosing begin/end will 00102 * be also written, otherwise only the data block will be written. 00103 * @return true if write was successful 00104 */ 00105 virtual bool write(ioHandler& handler,const bool complete=true) const; 00106 00107 /** 00108 * read the parameters from the given ioHandler 00109 * @param handler the ioHandler to be used 00110 * @param complete if true (the default) the enclosing begin/end will 00111 * be also written, otherwise only the data block will be written. 00112 * @return true if write was successful 00113 */ 00114 virtual bool read(ioHandler& handler,const bool complete=true); 00115 00116 # ifdef _LTI_MSC_6 00117 /** 00118 * this function is required by MSVC only, as a workaround for a 00119 * very awful bug, which exists since MSVC V.4.0, and still by 00120 * V.6.0 with all bugfixes (so called "service packs") remains 00121 * there... This method is also public due to another bug, so please 00122 * NEVER EVER call this method directly: use read() instead 00123 */ 00124 bool readMS(ioHandler& handler,const bool complete=true); 00125 00126 /** 00127 * this function is required by MSVC only, as a workaround for a 00128 * very awful bug, which exists since MSVC V.4.0, and still by 00129 * V.6.0 with all bugfixes (so called "service packs") remains 00130 * there... This method is also public due to another bug, so please 00131 * NEVER EVER call this method directly: use write() instead 00132 */ 00133 bool writeMS(ioHandler& handler,const bool complete=true) const; 00134 # endif 00135 00136 // ------------------------------------------------ 00137 // the parameters 00138 // ------------------------------------------------ 00139 00140 // comment the parameters of your functor 00141 // If you add more parameters manually, do not forget to do following: 00142 // 1. indicate in the default constructor the default values 00143 // 2. make sure that the copy member also copy your new parameters 00144 // 3. make sure that the read and write members also read and 00145 // write your parameters 00146 00147 /** 00148 * proportional scaling factor. Should be larger than 1. 00149 * 00150 * default 3 00151 */ 00152 int scaleFactor; 00153 00154 /** 00155 * visualize relative emission contibutions of states as 00156 * grey value encoding of state color along winner path. 00157 * 00158 * default = false 00159 */ 00160 bool emissions; 00161 00162 /** 00163 * show density selection along winner path as textual 00164 * info next to states. 00165 * 00166 * default = false; 00167 */ 00168 bool densities; 00169 00170 /** 00171 * draw looser paths into diagram. 00172 * 00173 * deafult = false 00174 */ 00175 bool loosers; 00176 00177 /** 00178 * the background color. default 0 (black) 00179 */ 00180 ubyte bgcol; 00181 00182 /** 00183 * the text color. default 255 (white) 00184 */ 00185 ubyte textcol; 00186 00187 /** 00188 * the color for the states in the state-time grid. Will also be 00189 * used for looser paths. default 64 (dark grey) 00190 */ 00191 ubyte statecol; 00192 00193 /** 00194 * the color of the winner path and the winner states. 00195 * \b Note that states of winner path will not have 00196 * this color, if parameter "emissions" is true. 00197 * 00198 * default 255 (white) 00199 */ 00200 ubyte winnercol; 00201 00202 }; 00203 00204 /** 00205 * default constructor 00206 */ 00207 hmmTrellisDiagram(); 00208 00209 /** 00210 * copy constructor 00211 * @param other the object to be copied 00212 */ 00213 hmmTrellisDiagram(const hmmTrellisDiagram& other); 00214 00215 /** 00216 * destructor 00217 */ 00218 virtual ~hmmTrellisDiagram(); 00219 00220 /** 00221 * returns the name of this type ("hmmTrellisDiagram") 00222 */ 00223 virtual const char* getTypeName() const; 00224 00225 // comment your apply methods! 00226 00227 /** 00228 * operates on the given %parameter. 00229 * @param seq the input observation sequence 00230 * @param hmm the hidden markov model to score the observation sequence 00231 * @param result the graphical output 00232 * @param text additional user defined text line to appear in output 00233 * @return true if apply successful or false otherwise. 00234 */ 00235 bool apply(const lti::sequence<lti::dvector>& seq, 00236 const lti::hiddenMarkovModel& hmm, 00237 lti::channel8& result, 00238 const std::string& text = "") const; 00239 00240 /** 00241 * copy data of "other" functor. 00242 * @param other the functor to be copied 00243 * @return a reference to this functor object 00244 */ 00245 hmmTrellisDiagram& copy(const hmmTrellisDiagram& other); 00246 00247 /** 00248 * alias for copy member 00249 * @param other the functor to be copied 00250 * @return a reference to this functor object 00251 */ 00252 hmmTrellisDiagram& operator=(const hmmTrellisDiagram& other); 00253 00254 /** 00255 * returns a pointer to a clone of this functor. 00256 */ 00257 virtual functor* clone() const; 00258 00259 /** 00260 * returns used parameters 00261 */ 00262 const parameters& getParameters() const; 00263 00264 // comment the attributes of your functor 00265 // If you add more attributes manually, do not forget to do following: 00266 // 1. indicate in the default constructor the default values 00267 // 2. make sure that the copy member also copy your new attributes, or 00268 // to ensure there, that these attributes are properly initialized. 00269 00270 }; 00271 } 00272 00273 #endif