ConnectedComponentAnalyzer.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  ConnectedComponentAnalyzer.cpp
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:  
00008  *  $Id: ConnectedComponentAnalyzer.h 44313 2011-04-06 22:46:28Z agas $ 
00009  *******************************************************************************/
00010 
00011 #ifndef CONNECTEDCOMPONENTANALYZER_H
00012 #define CONNECTEDCOMPONENTANALYZER_H
00013 
00014 #include <vector>
00015 #include <opencv2/opencv.hpp>
00016 #include "ConnectedComponent.h"
00017 
00018 
00025 class ConnectedComponentAnalyzer {
00026 
00027 public:
00028 
00030   ConnectedComponentAnalyzer();
00031 
00033   ~ConnectedComponentAnalyzer();
00034 
00046   std::vector< ConnectedComponent > segmentByLimit( cv::Mat* pi_img, double pi_limit );
00047 
00048 
00062   std::vector< ConnectedComponent > segment(unsigned char* binImage, unsigned width, unsigned height, unsigned minSegmentSize=1, float minOccupiedArea=0.0, unsigned expandSegmentSize=0);
00063   
00077   std::vector< ConnectedComponent > segment(const float* floatImage, unsigned width, unsigned height, float maxDistance, unsigned minSegmentSize=1, float minOccupiedArea=0.0, unsigned expandSegmentSize=0);
00078   std::vector< ConnectedComponent > segment(const float* floatImage, const unsigned char* mask, unsigned width, unsigned height, float maxDistance, unsigned minSegmentSize=1, float minOccupiedArea=0.0, unsigned expandSegmentSize=0, int maxr=1);
00079 
00081   static void isolateLargestSegment(unsigned char* binImage, unsigned width, unsigned height);
00082   
00086   unsigned* getLastLabelImage() { return m_LabelImage; }
00087   unsigned  getImageWidth() { return m_Width; }
00088   unsigned  getImageHeight() { return m_Height; }
00089                                                        
00090 private:
00091   
00104   std::vector<ConnectedComponent> extractComponents(unsigned max_label, unsigned minSegmentSize,
00105                                                     float minOccupiedArea, unsigned expandSegmentSize);
00106   
00108   template < typename T >
00109   struct IntensitySimilarity
00110   {
00111     private:
00112       T m_MaxDistance;
00113     public:
00114       IntensitySimilarity( T maxDistance ) : m_MaxDistance( maxDistance ) {}
00115       ~IntensitySimilarity() {}
00116       bool operator()( const T& l, const T& r ) const
00117       {
00118         T diff;
00119         if ( l < r ) {
00120           diff = r - l ;
00121         } else {
00122           diff = l - r;
00123         }
00124         return diff <= m_MaxDistance;
00125       }
00126   };
00127   
00129   template < typename MaskT, typename PixelT >
00130   struct MaskVadility
00131   {
00132     private:
00133       const MaskT* mask;
00134       const int colstep;
00135       const MaskT MASKED;
00136       
00137     public:
00138       MaskVadility( MaskT masked, const MaskT* mask, int colstep)
00139       : mask(mask), colstep(colstep), MASKED(masked)
00140       {}
00141       
00142       bool operator()(int idx, PixelT intensity ) const
00143       { return mask[ idx ] != MASKED; }
00144       
00145       
00146   };
00147   
00148   unsigned* m_LabelImage;
00149   unsigned  m_Width, m_Height;
00150 };
00151 
00152 
00153 #endif


or_libs
Author(s): raphael
autogenerated on Mon Oct 6 2014 02:53:18