contrib/gel/gevd/gevd_noise.h
Go to the documentation of this file.
00001 #ifndef gevd_noise_h_
00002 #define gevd_noise_h_
00003 
00004 // .NAME gevd_noise - Estimation of noise from histogram of weak responses
00005 //
00006 // Fit a Raleigh distribution to the histogram curve of all
00007 // edgels with low magnitudes, h(x), to estimate the sensor noise,
00008 // as would be zero-crossing of dh(x), and texture noise as the dominant
00009 // peak in h(x).
00010 //
00011 // Setting the threshold at 3 times the sensor/texture noise response
00012 // found would eliminate 99% of all noisy edges.
00013 // Knowing the filter, the standard deviation of noise in the original
00014 // image can be deduced from the above response values.
00015 // Assume no intensity truncation, if not, the sensor/texture noise has
00016 // been already artificially removed from the image, and so can not
00017 // be estimated.
00018 
00019 // - Input:      edgels in a typical ROI.
00020 // - Output:     histogram of low response edgels, and
00021 //               estimate of sensor/texture responses.
00022 // - Complexity: O(|data|) time and space.
00023 //
00024 // \verbatim
00025 //  Authors
00026 //   Harry Voorhees  (1987) SM Thesis
00027 //   Van-Duc Nguyen  (1989) CLOS implementation
00028 //   Van-Duc Nguyen  (1996) C++ implementation
00029 // \endverbatim
00030 
00031 class gevd_bufferxy;
00032 
00033 class gevd_noise
00034 {
00035  public:
00036   friend class DetectionUI;
00037   gevd_noise(const float* data, const int n, // data in a typical region
00038              const int number_of_bins=200);  // granularity of histogram
00039   ~gevd_noise();
00040 
00041   static float* EdgelsInCenteredROI(const gevd_bufferxy& magnitude,
00042                                     const gevd_bufferxy& dirx,
00043                                     const gevd_bufferxy& diry,
00044                                     int& nedgel,
00045                                     const int roiArea=250*250); // ROI
00046   bool EstimateSensorTexture(float& sensor, // sensor noise is would-be zc
00047                              float& texture) const; // texture is real zc
00048 
00049   const float* Histogram(int& n) const { n = nbin; return hist; }
00050   float BinSize() const { return binsize; } // size of bin in data unit
00051 
00052  protected:
00053   float* hist;   // histogram curve of low responses only
00054   int nbin;      // number of bins
00055   float binsize; // size of bin in data unit
00056 
00057  protected:
00058   static bool WouldBeZeroCrossing(const float* dhist, const int nbin,
00059                                   float& index);
00060   static bool RealZeroCrossing(const float* dhist, const int nbin,
00061                                float& index);
00062  private:
00063   gevd_noise() {} // no default constructor!
00064 };
00065 
00066 #endif // gevd_noise_h_