Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

graphSegmentation_Filter.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission :
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU Lesser 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.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU Lesser General Public License for more details.
00020 
00021     You should have received a copy of the GNU Lesser General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 #ifndef _GRAPHSEGMENTATION_FILTER_H
00027 #define _GRAPHSEGMENTATION_FILTER_H
00028 
00050 #include <phFilter.h>
00051 #include <algorithm>
00052 #include <cmath>
00053 
00054 /* ------------------------------------------------------------------------- */
00055 /*
00056  * Copyright (C) 2006 Pedro Felzenszwalb
00057  * 
00058  * This program is free software; you can redistribute it and/or modify
00059  * it under the terms of the GNU General Public License as published by
00060  * the Free Software Foundation; either version 2 of the License, or
00061  * (at your option) any later version.
00062  * 
00063  * This program is distributed in the hope that it will be useful,
00064  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00065  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00066  * GNU General Public License for more details.
00067  * 
00068  * You should have received a copy of the GNU General Public License
00069  * along with this program; if not, write to the Free Software
00070  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00071  */
00072 /* ------------------------------------------------------------------------- */
00073 /* From segment/disjoint-set.h/cpp */
00074 /* ------------------------------------------------------------------------- */
00075 /* disjoint-set forests using union-by-rank and path compression (sort of). */
00076 typedef struct ph_uni_elt_t
00077 {
00078     int rank;
00079     int p;
00080     int size;
00081 } ph_uni_elt;
00082 
00083 PHAPI(class) phUniverse 
00084 {
00085 private:
00086     ph_uni_elt *m_elts;
00087     uint32_t    m_elts_size; /* added for phDALLOC */
00088     uint32_t    m_elt_count;
00089     uint32_t    m_num;
00090 
00091 public:
00092     phUniverse( uint32_t elements );
00093     ~phUniverse();
00094 
00095     void    resize  ( uint32_t elements );
00096     
00097     int     find    ( int x );  
00098     void    join    ( int x, int y);
00099     int     size    ( int x ) const;
00100     uint32_t num_sets() const;
00101 
00102 };
00103 
00104 /* ------------------------------------------------------------------------- */
00105 /* From segment/segment-graph.h/cpp */
00106 /* ------------------------------------------------------------------------- */
00107 
00108 typedef struct {
00109   float w;
00110   int a, b;
00111 } ph_edge;
00112 
00113 bool operator<(const ph_edge &a, const ph_edge &b);
00114 
00115 /* ------------------------------------------------------------------------- */
00116 /* End Pablo Felzenszwalb Copyright; for this file */
00117 /* ------------------------------------------------------------------------- */
00118 
00124 /* ------------------------------------------------------------------------- */
00138 PHAPI(class) graphSegmentation_Filter : public phFilter
00139 {
00140 private:
00144     uint32_t        m_num_edges;
00145     ph_edge        *m_edges;
00146     uint32_t        m_edges_size;
00147     
00148     phUniverse     *m_universe;
00149 
00150     float          *m_thresholds;
00151     uint32_t        m_thresholds_size;
00152     
00153     uint8_t        *m_output;
00154     uint32_t        m_output_size;
00155 
00156     /* minimum component size from post processing */
00157     uint32_t        m_min_size;
00158     /* k from the original graph-based algorithm */
00159     uint32_t        m_thresh;
00160     /* turn on/off the coloring of the output image */
00161     int             m_color_blobs;
00162 
00163     void SegmentImage();
00164     int  SegmentGraph();
00165     void ProcessGraph();
00166 
00167 protected:
00172     int filter();
00173 
00174 public:
00188     graphSegmentation_Filter( uint32_t  min_size    = 250, 
00189                               uint32_t  threshold   = 450,
00190                               int       color_blobs = 1 );
00191     ~graphSegmentation_Filter();
00192     
00201     int set( uint32_t   min_size,
00202              uint32_t   threshold,
00203              int        color_blobs );
00204 
00205     int setMinSize      ( uint32_t min_size     );
00206     int setThreshold    ( uint32_t threshold    );
00207     int setColorBlobs   ( int      color_blobs  );
00208 
00209     uint32_t getMinSize     ();
00210     uint32_t getThreshold   ();
00211     int      getColorBlobs  ();
00212     
00221     phFilter *cloneFilter();
00222 
00223 };
00224  /* ImageProcessing */
00226 
00227 #endif /* _EMPTY_FILTER_H */
00228 




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:08 2007 for phission by  doxygen 1.4.4