Tesseract  3.02
tesseract-ocr/cube/feature_chebyshev.h
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        feature_chebyshev.h
00003  * Description: Declaration of the Chebyshev coefficients Feature Class
00004  * Author:    Ahmad Abdulkader
00005  * Created:   2008
00006  *
00007  * (C) Copyright 2008, Google Inc.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 // The FeatureChebyshev class implements a Bitmap feature extractor class. It
00021 // inherits from the FeatureBase class
00022 // The feature vector is the composed of the chebyshev coefficients of 4 time
00023 // sequences. The time sequences are the left, top, right & bottom
00024 // bitmap profiles of the input samples
00025 
00026 #ifndef FEATURE_CHEBYSHEV_H
00027 #define FEATURE_CHEBYSHEV_H
00028 
00029 #include "char_samp.h"
00030 #include "feature_base.h"
00031 
00032 namespace tesseract {
00033 class FeatureChebyshev : public FeatureBase {
00034  public:
00035   explicit FeatureChebyshev(TuningParams *params);
00036   virtual ~FeatureChebyshev();
00037   // Render a visualization of the features to a CharSamp.
00038   // This is mainly used by visual-debuggers
00039   virtual CharSamp *ComputeFeatureBitmap(CharSamp *samp);
00040   // Compute the features for a given CharSamp
00041   virtual bool ComputeFeatures(CharSamp *samp, float *features);
00042   // Returns the count of features
00043   virtual int FeatureCnt() {
00044     return (4 * kChebychevCoefficientCnt);
00045   }
00046 
00047  protected:
00048   static const int kChebychevCoefficientCnt = 40;
00049   // Compute Chebychev coefficients for the specified vector
00050   void ChebyshevCoefficients(const vector<float> &input,
00051                              int coeff_cnt, float *coeff);
00052   // Compute the features for a given CharSamp
00053   bool ComputeChebyshevCoefficients(CharSamp *samp, float *features);
00054 };
00055 }
00056 
00057 #endif  // FEATURE_CHEBYSHEV_H