getLines.h

Go to the documentation of this file.
00001 /***************************************************************************/  
00002   
00028 #ifndef __getLines_H  
00029 #define __getLines_H  
00030   
00031 #include <tiff.h>  
00032 #include <DLConnectedComponents.h>  
00033   
00034 using namespace std;  
00035   
00036 const static  char DL_GETLINES_VERSION[] =  "getLinesDOCLIB Beta v1.0 - $Name:  $";
00037 
00038 
00039 /***************************************************************************  
00040 STRUCTURE DECLARATIONS  
00041 ***************************************************************************/  
00042   
00046 typedef struct {  
00048    int number;  
00049   
00051    int height;  
00052 } compInfo;  
00053   
00057 typedef struct {  
00059    int prev;  
00060   
00062    int next;  
00063 } lineList;  
00064   
00068 struct pointLoc {  
00070    int x;  
00071   
00073    int y;  
00074 };  
00075   
00079 typedef struct {  
00081    int compCount;  
00082   
00084    float slope;  
00085   
00087    float yIntercept;  
00088   
00090    float avgHeight;  
00091   
00093    float avgWidth;  
00094   
00096    int height;  
00097   
00099    int width;  
00100   
00102    float sqrLength;  
00103   
00105    float upperExt;  
00106   
00108    float lowerExt;  
00109   
00111    int *compList;  
00112   
00114    int mergedFlag;  
00115   
00122    struct pointLoc loc[4];  
00123 } DLlineInfo;  
00124   
00128 typedef struct {  
00130    int hnode_wt;  
00131   
00133    int vnode_wt;  
00134   
00136    int hto_edge;  
00137   
00139    int vto_edge;  
00140   
00142    int hfrom_edge;  
00143   
00145    int vfrom_edge;  
00146 } DLnodes;  
00147   
00152 typedef struct {  
00154    float hor_mean;  
00155   
00157    float ver_mean;  
00158   
00162    float asr;  
00163   
00166    float hor_num;  
00167   
00170    float ver_num;  
00171   
00174    float hor_dx;  
00175   
00178    float ver_dy;  
00179 } DLstats;  
00180   
00181 /***************************************************************************  
00182 CLASS DECLARATION  
00183 ***************************************************************************/  
00184   
00249 // The below diagram is the same as the above but not formatted for Doxygen.  
00250 /*  
00251     (x1, y1)  
00252     |  
00253     v  
00254     |--------------------------------------|  
00255     |                                 #### |  
00256     |                        #       #    #|  
00257     |          ####  #       #       #    #|  
00258     |#    #  ##      #       #      -------|<-(x4, y4)  
00259     |#    #  # ####  #   ----------/ #    #|  
00260     |######  ##---------/    #        #### |  
00261     (x3, y3)->|---------/      #   ##  ######        |  
00262     |#    #  # ####  ####                  |  
00263     |#    #  ##                            |  
00264     |--------------------------------------|  
00265     ^  
00266     |  
00267     (x2, y2)  
00268 */  
00269 class getLines {  
00270    public:  
00271    /***********************************************************************  
00272     VARIABLES  
00273    ***********************************************************************/  
00274   
00277    DLlineInfo *imageObj;  
00278   
00279    /***********************************************************************  
00280     CONSTRUCTOR AND DESTRUCTOR METHODS  
00281    ***********************************************************************/  
00282   
00296    getLines(DLImage emu);  
00297   
00299    ~getLines();  
00300   
00301    /***********************************************************************  
00302     REGULAR METHODS  
00303    ***********************************************************************/  
00304   
00307    void dlPrintLineInfo();  
00308    void dlPrintLineInfo1(std::string fname, DLlineInfo *,int );  
00309   
00314    void dlPrintLineInfo(std::string fname);  
00315   
00327    void dlRecalculate();  
00328   
00329    /***********************************************************************  
00330     GET METHODS  
00331    ***********************************************************************/  
00332   
00336    float dlGetAvgHeight() const { return(_avgHeightText); }  
00337   
00341    float dlGetAvgSlope() const { return(_avgSlope); }  
00342   
00346    float dlGetAvgWidth() const { return(_avgWidthText); }  
00347   
00351    DLlineInfo *dlGetInfo() const { return(imageObj); }  
00352   
00355    int dlGetLineCount() const { return(_lineCount); }  
00356   
00359    float dlGetMaxIntercept() const { return(_maxIntercept); }  
00360   
00363    float dlGetMaxSlope() const { return(_maxSlope); }  
00364   
00367    int dlGetMaxTextCol() const { return(_maxXText); }  
00368   
00371    int dlGetMaxTextHeight() const { return(_maxHeightText); }  
00372   
00375    int dlGetMaxTextRow() const { return(_maxYText); }  
00376   
00379    int dlGetMaxTextWidth() const { return(_maxWidthText); }  
00380   
00383    float dlGetMinIntercept() const { return(_minIntercept); }  
00384   
00387    float dlGetMinSlope() const { return(_minSlope); }  
00388   
00391    int dlGetMinTextCol() const { return(_minXText); }  
00392   
00395    int dlGetMinTextHeight() const { return(_minHeightText); }  
00396   
00399    int dlGetMinTextRow() const { return(_minYText); }  
00400   
00403    int dlGetMinTextWidth() const { return(_minWidthText); }  
00404   
00409    float dlGetSlopeVariance() const { return(_varSlope); }  
00410   
00415    float dlGetTextVarianceHeight()  
00416       const { return(_varHeightText); }  
00417   
00422    float dlGetTextVarianceWidth()  
00423       const { return(_varWidthText); }  
00424   
00425    /***********************************************************************  
00426             SET METHODS  
00427    ***********************************************************************/  
00428   
00436    void dlSetFilterCCDensity(float dens)  
00437       { _densityCCLess = dens; }  
00438   
00445    void dlSetFilterCCHeightBetween(int low, int high)  
00446       { _lowCCHeight = low; _highCCHeight = high; }  
00447   
00454    void dlSetFilterCCWidthBetween(int low, int high)  
00455       { _lowCCWidth = low; _highCCWidth = high; }  
00456   
00462    void dlSetMaxToMedianRatio(float max)  
00463       { _maxToMedianRatio = max; }  
00464   
00470    void dlSetMinAvgHeight(int min)  
00471       { _minAvgHeight = min; }  
00472   
00473    static string dlGetVersionInfo();
00474 
00475    protected:  
00476    /***********************************************************************  
00477     GET METHOD VARIABLES  
00478    ***********************************************************************/  
00479   
00481    float _avgHeightText;  
00482   
00485    float _avgSlope;  
00486   
00488    float _avgWidthText;  
00489   
00491    int _lineCount;  
00492   
00494    int _maxHeightText;  
00495   
00497    float _maxIntercept;  
00498   
00500    float _maxSlope;  
00501   
00503    int _maxWidthText;  
00504   
00506    int _maxXText;  
00507   
00509    int _maxYText;  
00510   
00512    int _minHeightText;  
00513   
00515    float _minIntercept;  
00516   
00518    float _minSlope;  
00519   
00521    int _minWidthText;  
00522   
00524    int _minXText;  
00525   
00527    int _minYText;  
00528   
00530    float _varHeightText;  
00531   
00533    float _varSlope;  
00534   
00536    float _varWidthText;  
00537   
00538    /***********************************************************************  
00539     SET METHOD VARIABLES  
00540    ***********************************************************************/  
00541   
00545    float _densityCCLess;  
00546   
00549    int _highCCHeight;  
00550   
00553    int _highCCWidth;  
00554   
00557    int _lowCCHeight;  
00558   
00561    int _lowCCWidth;  
00562   
00566    float _maxToMedianRatio;  
00567   
00570    int _minAvgHeight;  
00571   
00572    private:  
00573    /***********************************************************************  
00574     VARIABLES  
00575    ***********************************************************************/  
00576   
00579    float avgHeightCC;  
00580   
00583    float avgWidthCC;  
00584   
00586    int emuCCSize;  
00587   
00589    DLImage emuBW;  
00590   
00592    DLConnectedComponents emuCC;  
00593   
00595    vector <DLComponent> emuCCList;  
00596   
00598    vector <DLComponent> emuCCListFilt;  
00599 
00603    int emuCCListFiltRowMaxVal;
00604   
00607    DLImage emuColor;  
00608   
00610    int emuSize;  
00611   
00615    float factor;  
00616   
00617    /***********************************************************************  
00618     METHODS  
00619    ***********************************************************************/  
00620   
00625    void dlBuildLineInfo(int *line_segs, DLlineInfo *textLines,  
00626                         int *line_count);  
00627   
00674    // The below diagram is the same as the above but not formatted for  
00675    // Doxygen.  
00676    /*  
00677        -  
00678        -  
00679        -  
00680        -    |  
00681        -  _____| SLOPE  
00682        -  
00683        -  
00684        -  
00685        -         TO THE RIGHT  
00686        x_________________________> DD (radius)  
00687        -  
00688        |  \   -  
00689        -  
00690        |      \       -  
00691        -  
00692        |          \           -  
00693        -  
00694        |  BELOW       \               -  
00695        -  
00696        |                  \  
00697   
00698        |                    \  
00699   
00700        |                        \  
00701    */  
00702    void dlCalcHorizontalNeighbors(int *iList, int **iEdges);  
00703   
00710    void dlCombineLines(DLlineInfo *originalList, DLlineInfo *newList,  
00711                        int line1, int line2, int newIndex);  
00712   
00715    void dlCompLineInfo();  
00716   
00722    void dlComputeLines(DLlineInfo **textLines, int maxIterations,  
00723                        int *iList, int *finalLineCount);  
00724   
00732    void dlCopyToNewLineList(DLlineInfo *originalList, DLlineInfo *newList,  
00733                             int line1, int newIndex);  
00734   
00737    void dlCreateComponentList(int **iList);  
00738   
00742    void dlFreeLineInfo(DLlineInfo *textLines, int line_count);  
00743   
00749    void dlGetCompMinDistance(DLComponent *comp1, DLComponent *comp2,  
00750                              float *min_dist);  
00751   
00760    void dlLeastSquaresFit(float *x, float *y, int size, float *slope,  
00761                           float *intercept);  
00762   
00778    double dlLineDistance(double a1, double b1, double a2, double b2,  
00779                          double l1x1, double l1x2, double l2x1, double l2x2, double *lineSepX1,  
00780                          double *lineSepX2);  
00781   
00791    void dlLineExtension(DLlineInfo *textLine, int line_count);  
00792 
00797    void dlGenerateAnnotatedImage(DLImage image, char *fname,
00798                                  DLColorMapValue color);
00799   
00802    void dlLineStats(DLlineInfo *textLine);  
00803   
00818    void dlProject(double l1x1, double l1y1, double l1x2, double l1y2,  
00819                   double l2x1, double l2y1, double l2x2, double l2y2, double *limits1,  
00820                   double *projects2, double *distance2);  
00821   
00826    void dlPutOnList(DLnodes *N1, int i1, int j1);  
00827   
00832    void dlRemoveOutliers(DLlineInfo *newTextLines, int line_count);  
00833 }; // end getLines class  
00834   
00835 #endif  

Generated on Fri Feb 23 13:21:07 2007 for DLGetLines by  doxygen 1.5.1