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 
00048 #include <phFilter.h>
00049 
00050 /* ------------------------------------------------------------------------- */
00051 /*
00052  * Copyright (C) 2006 Pedro Felzenszwalb
00053  * 
00054  * This program is free software; you can redistribute it and/or modify
00055  * it under the terms of the GNU General Public License as published by
00056  * the Free Software Foundation; either version 2 of the License, or
00057  * (at your option) any later version.
00058  * 
00059  * This program is distributed in the hope that it will be useful,
00060  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00061  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00062  * GNU General Public License for more details.
00063  * 
00064  * You should have received a copy of the GNU General Public License
00065  * along with this program; if not, write to the Free Software
00066  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00067  */
00068 /* ------------------------------------------------------------------------- */
00069 /* From segment/disjoint-set.h/cpp */
00070 /* ------------------------------------------------------------------------- */
00071 /* disjoint-set forests using union-by-rank and path compression (sort of). */
00072 typedef struct ph_uni_elt_t
00073 {
00074     int rank;
00075     int p;
00076     int size;
00077 } ph_uni_elt;
00078 
00079 PHAPI(class) phUniverse 
00080 {
00081 private:
00082     ph_uni_elt *m_elts;
00083     uint32_t    m_elts_size; /* added for phDALLOC */
00084     uint32_t    m_elt_count;
00085     uint32_t    m_num;
00086 
00087 public:
00088     phUniverse( uint32_t elements );
00089     ~phUniverse();
00090 
00091     void    resize  ( uint32_t elements );
00092     
00093     int     find    ( int x );  
00094     void    join    ( int x, int y );
00095     int     size    ( int x ) const;
00096     uint32_t num_sets() const;
00097 
00098 };
00099 
00100 /* ------------------------------------------------------------------------- */
00101 /* From segment/segment-graph.h/cpp */
00102 /* ------------------------------------------------------------------------- */
00103 
00104 typedef struct {
00105   float w;
00106   int a, b;
00107 } ph_edge;
00108 
00109 bool operator<(const ph_edge &a, const ph_edge &b);
00110 
00111 /* ------------------------------------------------------------------------- */
00112 /* End Pablo Felzenszwalb Copyright; for this file */
00113 /* ------------------------------------------------------------------------- */
00114 
00120 /* ------------------------------------------------------------------------- */
00134 PHAPI(class) graphSegmentation_Filter : public phFilter
00135 {
00136 private:
00140     uint32_t        m_num_edges;
00141     ph_edge        *m_edges;
00142     uint32_t        m_edges_size;
00143     
00144     phUniverse     *m_universe;
00145 
00146     float          *m_thresholds;
00147     uint32_t        m_thresholds_size;
00148     
00149     uint8_t        *m_output;
00150     uint32_t        m_output_size;
00151 
00152     /* minimum component size from post processing */
00153     uint32_t        m_min_size;
00154     /* k from the original graph-based algorithm */
00155     uint32_t        m_thresh;
00156     uint32_t        m_last_thresh;
00157     uint32_t        m_last_thresholds_size;
00158     /* turn on/off the coloring of the output image */
00159     int             m_color_blobs;
00160 
00161     void SegmentImage();
00162     int  SegmentGraph();
00163     void ProcessGraph();
00164 
00165 protected:
00170     int filter();
00171 
00172 public:
00186     graphSegmentation_Filter( uint32_t  min_size    = 250, 
00187                               uint32_t  threshold   = 450,
00188                               int       color_blobs = 1 );
00189     ~graphSegmentation_Filter();
00190     
00199     int set( uint32_t   min_size,
00200              uint32_t   threshold,
00201              int        color_blobs );
00202 
00203     int setMinSize      ( uint32_t min_size     );
00204     int setThreshold    ( uint32_t threshold    );
00205     int setColorBlobs   ( int      color_blobs  );
00206 
00207     uint32_t getMinSize     ();
00208     uint32_t getThreshold   ();
00209     int      getColorBlobs  ();
00210     
00219     phFilter *cloneFilter();
00220 
00221 };
00222  /* ImageProcessing */
00224 
00225 #endif /* _EMPTY_FILTER_H */
00226 




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