00001 #ifndef __REulerElasticaInpainter__ 00002 #define __REulerElasticaInpainter__ 00003 00028 #include <stdio.h> 00029 00030 #include "RImage.hpp" 00031 #include "AbsRImageFilter.hpp" 00032 00033 class REulerElasticaInpainter : public AbsRImageFilter 00034 { 00035 private: 00036 00037 bool optimisation; // Marquina optimisation 00038 00039 double a, b; 00040 00041 double dt; 00042 00043 RImage* I0; 00044 RImage* I; 00045 00046 double lambda; 00047 00048 00049 RImage* kDu; 00050 RImage* k; 00051 00052 // curvature computation 00053 double kDu_x2, kDu_y2, k_2; 00054 double ux2, uy2, gu2Norme; 00055 double ux2Norme, uy2Norme; 00056 00057 protected: 00058 00059 void precompute(AnImage* mask); 00060 00061 void computeGradient(int x, int y, int idx, int idy); 00062 void computeCurvature(int x, int y, int idx, int idy); 00063 00064 double getV(int x, int y, int idx, int idy); 00065 00066 double divergentV(int x, int y) 00067 { return ( getV(x,y,1,0)-getV(x,y,-1,0) + getV(x,y,0,1)-getV(x,y,0,-1) ); } 00068 00069 double operation(int x, int y); 00070 00071 public: 00072 00073 REulerElasticaInpainter(bool optimised= false, double deltaT=1.0, 00074 double av=0.2, double bv=0.2, double lambdav=0.0); 00075 virtual ~REulerElasticaInpainter(){} 00076 00077 virtual void prepare(RImage* src); // used to globally maintain subimages avoiding cons 00078 virtual void clear(){ delete kDu; delete k; } 00079 00080 00081 // single shot filtering 00082 virtual RImage* filter(RImage* src, RImage* dest=0){ return 0; } 00083 virtual RImage* selectedFilter(AnImage* mask, RImage* src, RImage* dest=0); 00084 00085 virtual void report(FILE* file){ fprintf(file,"Real Bertalmio Inpainter\n"); } 00086 }; 00087 00088 00089 #endif