ImageMaskCV.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  ImageMaskCV.h
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:
00008  *  $Id: $
00009  *******************************************************************************/
00010 
00011 #ifndef ImageMaskCV_H
00012 #define ImageMaskCV_H
00013 
00014 #include <opencv2/opencv.hpp>
00015 #include <opencv2/highgui/highgui.hpp>
00016 
00017 #include "Workers/Math/Box2D.h"
00018 
00019 
00026 class ImageMaskCV
00027 {
00028   public:
00029 
00030     enum MaskValues {
00031       MASKED = 0,
00032       VISIBLE = 255
00033     };
00034 
00036     ImageMaskCV( );
00037 
00039     ImageMaskCV( const ImageMaskCV& other );
00040     ImageMaskCV& operator=( const ImageMaskCV& other );
00041 
00043     ImageMaskCV( unsigned width, unsigned height, unsigned char* data=0 );
00044 
00046     ImageMaskCV( unsigned width, unsigned height, unsigned char* data, char maskedMin, char maskedMax );
00047 
00049     ImageMaskCV( cv::Mat& image, unsigned char minVal, unsigned char maxVal=255 );
00050 
00052     ImageMaskCV(cv::Mat& foregroundY, cv::Mat& foregroundUv,
00053               cv::Mat& backgroundY, cv::Mat& backgroundUv,
00054               int threshold );
00055 
00057     ~ImageMaskCV();
00058 
00059     void apply( cv::Mat& image, unsigned char fillValue=0 );
00060     void apply( cv::Mat& image, unsigned char fillR, unsigned char fillG, unsigned char fillB );
00061 
00063     void grayOut( cv::Mat& colorImage, cv::Mat& graimageY );
00064     void grayOut( cv::Mat& colorImage );
00065 
00067     bool findValue( int x, int y, unsigned char value, float radius );
00068 
00073     void erode( float radius=1.0 );
00074 
00079     void dilate( float radius=1.0 );
00080 
00082     void fill( unsigned char value );
00083 
00085     void expand( const ImageMaskCV& other );
00086 
00088     void findBorders( );
00089 
00091     Point2D getGravCenter( );
00092 
00093     Box2D<int> getBoundingBox();
00094 
00096     ImageMaskCV* subMask( Box2D<int> area );
00097 
00103     unsigned char* getData() { return m_Data; }
00104 
00105     inline unsigned getWidth() { return m_Width; }
00106     inline unsigned getHeight() { return m_Height; }
00107 
00108   private:
00109 
00110     enum maskOperationT{
00111       dilateOperation,
00112       erodeOperation
00113     };
00114 
00115     void maskOperation( maskOperationT operation, float radius );
00116 
00118     void createCircularKernel( float radius, int*& maskOffset, int& halfMaskSize, unsigned& maskLength );
00119 
00120     unsigned char* m_Data;
00121 
00122     unsigned m_Width;
00123     unsigned m_Height;
00124 
00125 };
00126 
00127 #endif


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