Vista     Main Page   Class List   Function List   File List   Examples  


CMotion2DImage.h

Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (c) 1995-2005 by INRIA.
00004   All Rights Reserved.
00005 
00006   This software was developed at:
00007   IRISA/INRIA Rennes
00008   Campus Universitaire de Beaulieu
00009   35042 Rennes Cedex
00010 
00011   http://www.irisa.fr
00012 
00013 */
00014 
00080 #ifndef CMotion2DImage_h
00081 #define CMotion2DImage_h
00082 
00083 #ifdef __SunOS_
00084 # include <iostream.h>
00085 #else
00086 # include <iostream>
00087 #endif
00088 #include <math.h>
00089 
00090 using namespace std;
00091 
00092 #if defined (WIN32)
00093 #  if defined MOTION2D_DLL_EXPORTS
00094 #     define MOTION2D_API __declspec( dllexport )
00095 #  elif defined MOTION2D_DLL_IMPORTS
00096 #     define MOTION2D_API __declspec( dllimport )
00097 #  else
00098 #     define MOTION2D_API
00099 #  endif
00100 #else
00101 #     define MOTION2D_API
00102 #endif
00103 
00104 #ifndef FILENAME_MAX
00105 #  define FILENAME_MAX 1024
00106 #endif
00107 
00108 
00109 #define DEBUG_LEVEL1 0
00110 
00121 template <class T> bool sort(unsigned n, T* ra)
00122 {
00123   unsigned long l,j,ir,i;
00124   T rra;
00125   unsigned long min,max;
00126 
00127   if (DEBUG_LEVEL1) cout << "Begin sort()" << endl;
00128   if (n == 0)
00129     return false;
00130 
00131   if (n == 1)
00132     return true;
00133 
00134   min=n+1;
00135   max= 0; // -1 Modif FS 13/05/04
00136   l=(n >> 1)+1;
00137   ir=n;
00138   for (;;) {
00139     if (l > 1)
00140       rra=ra[--l];
00141     else {
00142       rra=ra[ir];
00143       ra[ir]=ra[1];
00144       if (ir>max) max=ir;
00145       if (ir<min) min=ir;
00146       if (--ir == 1) {
00147         ra[1]=rra;
00148 
00149         return true;
00150       }
00151     }
00152     i=l;
00153     j=l << 1;
00154     while (j <= ir) {
00155       if (j+1>max) max=j+1;
00156       if (j<min) min=j;
00157       if (j < ir && ra[j] < ra[j+1]) ++j;
00158       if (rra < ra[j]) {
00159         if (i>max) max=i;
00160         if (i<min) min=i;
00161         ra[i]=ra[j];
00162         j += (i=j);
00163       }
00164       else j=ir+1;
00165     }
00166     if (i>max) max=i;
00167     if (i<min) min=i;
00168     ra[i]=rra;
00169   }
00170   if (DEBUG_LEVEL1) cout << "End sort()" << endl;
00171   return true;
00172 }
00173 
00174 
00175 
00176 
00177 template<class Type>
00178 class CMotion2DImage
00179 {
00180 private:
00181   unsigned npixels;
00182   unsigned ncols ;
00183   unsigned nrows ;
00184 
00185 public:
00186   Type *bitmap ; 
00187   Type **row ; 
00189 public:
00190   CMotion2DImage() ;
00191   //copy constructors
00192   CMotion2DImage(const CMotion2DImage<Type>&);
00193   CMotion2DImage(unsigned nb_rows, unsigned nb_cols);
00194   CMotion2DImage(unsigned nb_rows, unsigned nb_cols, Type value);
00195   ~CMotion2DImage() ;
00196 
00197   bool Init(unsigned nb_rows, unsigned nb_cols);
00198   bool Init(unsigned nb_rows, unsigned nb_cols, Type value);
00199 
00200   bool Resize(unsigned nb_rows, unsigned nb_cols);
00201   void Subsample();
00202   bool And(CMotion2DImage<Type> &A, CMotion2DImage<Type> &B);
00203   bool And(CMotion2DImage<Type> &A, CMotion2DImage<Type> &B, Type label);
00204   bool MedianFilter(unsigned filterRowSize, unsigned filterColSize);
00205 
00211   inline unsigned GetRows() const { return nrows ; }
00217   inline unsigned GetCols() const { return ncols ; }
00224   inline unsigned GetNumberOfPixel() const{ return npixels; }
00225 
00232   Type *operator[](unsigned i) {return row[i];}
00239   const  Type *operator[](unsigned i) const {return row[i];}
00240 
00241 
00242   void operator=(Type x);
00243 
00244   void operator=(const CMotion2DImage<Type> &image);
00245 
00246   CMotion2DImage<Type> operator-(const CMotion2DImage<Type> &image);
00247 
00248 private:
00254   void SetCols(unsigned nb_cols) { ncols = nb_cols ; } ;
00260   void SetRows(unsigned nb_rows) { nrows = nb_rows ; } ;
00261 
00262 
00263 } ;
00264 
00265 
00266 #include <CMotion2DImage_base.cpp>
00267 
00268 // Include for image ios
00269 #include "Motion2DImage_PNM.h"
00270 #include "Motion2DImage_RAW.h"
00271 #include "Motion2DImage_PNG.h"
00272 
00273 #undef DEBUG_LEVEL1
00274 
00275 
00276 #endif

Motion2D is Copyright © 1995-2005 by Inria
This documentation was generated on 31 Jan 2005 by Fabien Spindler for Motion2D 1.3.11 using doxygen1.2.18 written by Dimitri van Heesch, © 1997-2005