00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00021 #ifndef _Normalization_hpp
00022 #define _Normalization_hpp
00023
00024 #include<ImLib3D/ImageProcessor.hpp>
00025 #include<ImLib3D/ImageStats.hpp>
00026 #include<ImLib3D/Signal1D.hpp>
00027
00028 namespace IP3D
00029 {
00038 void NormalizeAverage(const Image3Df& src,const Image3Df& ref,Image3Df& res);
00039 };
00040
00041 namespace IP3D
00042 {
00051 void NormalizeAverageAndVariance(const Image3Df& src,const Image3Df& ref,Image3Df& res);
00052 };
00053
00054
00055
00057 class JointHistogram
00058 {
00059
00060 public:
00061 int nbSrcBins;
00062 int nbRefBins;
00063 Image3Df histogramImage;
00065 double srcMin;
00067 double srcMax;
00069 double refMin;
00071 double refMax;
00072
00074
00075 inline float SrcBinF(float v) const {return nbSrcBins *(v-srcMin)/(srcMax-srcMin);}
00076 inline float RefBinF(float v) const {return nbRefBins *(v-refMin)/(refMax-refMin);}
00077 inline int SrcBin(float v) const {return (int)rint(SrcBinF(v));}
00078 inline int RefBin(float v) const {return (int)rint(RefBinF(v));}
00079 inline double SrcVal(int x) const {return (srcMin+x*(srcMax-srcMin)/(double)nbSrcBins );}
00080 inline double SrcVal(double x) const {return (srcMin+x*(srcMax-srcMin)/(double)nbSrcBins );}
00081 inline double RefVal(int y) const {return (refMin+y*(refMax-refMin)/(double)nbRefBins);}
00082 inline double RefVal(double y) const {return (refMin+y*(refMax-refMin)/(double)nbRefBins);}
00083 inline int SSrcBin(float v) const {return min(nbSrcBins -1,max(0,SrcBin(v)));}
00084 inline int SRefBin(float v) const {return min(nbRefBins-1 ,max(0,RefBin(v)));}
00086 float SrcLimit(float v) const {return min((float)srcMax,max(v,(float)srcMin));}
00087 float RefLimit(float v) const {return min((float)refMax,max(v,(float)refMin));}
00088 protected:
00090 void ComputeFromIndependentSamples(const Image3Df &src,const Image3Df &ref);
00092 void ComputeFromDirectionalLinearInterpolation(const Image3Df &src,const Image3Df &ref,int dir);
00094 virtual void FindRanges(const Image3Df& src, const Image3Df &ref);
00096 JointHistogram(int _nbSrcBins=100,int _nbRefBins=400) :
00097 nbSrcBins(_nbSrcBins),nbRefBins(_nbRefBins),histogramImage(_nbSrcBins,_nbRefBins,1) {;}
00098 public:
00099 virtual ~JointHistogram(){;}
00100 public:
00102 void AddDisplayGrid();
00104 float GetSrcBinTotalProba(int x) const;
00106 Signal1Df MedianTransferFct() const ;
00108 Signal1Df MaximumProbabilityTransferFct() const;
00110
00111 Signal1Df BestFitTransferFct(double smoothingCoef=1,bool allowDecreasing=false) const;
00113
00115 static Signal1Df SmoothAndExtend(const Signal1Df &src,const Signal1Df &weights,double smoothSigma,double outlierSigma);
00117 Signal1Df ConfidenceWeights() const;
00118
00119
00120 JointHistogram(const string &filename);
00121 JointHistogram(const Image3Df &src,const Image3Df &ref,int _nbSrcBins=100,int _nbRefBins=400);
00122 };
00123
00124 namespace IP3D
00125 {
00136 void ComputeJointHistogramImage(const Image3Df& src,const Image3Df& ref,Image3Df& res,int drawTransferFunction=0,int nbSrcBins=100,int nbRefBins=200);
00137 };
00138
00139
00140 namespace IP3D
00141 {
00152 void NormalizeJointHistogram(const Image3Df& src,const Image3Df& ref,Image3Df& res,int nbSrcBins=100,int nbRefBins=200);
00153 };
00154
00155 #endif// _Normalization_hpp