00001 // This is gel/vifa/vifa_norm_params.h 00002 #ifndef VIFA_NORM_PARAMS_H 00003 #define VIFA_NORM_PARAMS_H 00004 00005 //----------------------------------------------------------------------------- 00006 //: 00007 // \file 00008 // \brief Parameter mixin for intensity normalization. 00009 // 00010 // These parameters govern a linear normalization of intensity values from 00011 // some arbitrary range to [0,1]. If the raw intensity range is the x-axis, 00012 // and the normalized range is the y-axis, then two points, "high" and "low", 00013 // are given. A line is fit to these two points, and the two x-coordinates 00014 // where y==0 and y==1 are the intensity minimum and maximum clip points, 00015 // imin_ and imax_. The context is that the y-coordinates of high and low 00016 // points are found by histogramming the source image, and picking the (say) 00017 // 5% and 95% points. 00018 // 00019 // The defaults are interpreted by the normalize() routine as a no-op: no 00020 // normalization is performed. 00021 // 00022 // \author Roddy Collins, from DDB in TargetJr 00023 // 00024 // \date Oct 2001 00025 // 00026 // \verbatim 00027 // Modifications: 00028 // MPP Mar 2003, Ported to VXL 00029 // \endverbatim 00030 //----------------------------------------------------------------------------- 00031 00032 #include <vbl/vbl_ref_count.h> 00033 #include <vbl/vbl_smart_ptr.h> 00034 #include <vil/vil_image_view_base.h> 00035 #include <vul/vul_timestamp.h> 00036 #include <gevd/gevd_param_mixin.h> 00037 00038 00039 class vifa_norm_params : public gevd_param_mixin, 00040 public vul_timestamp, 00041 public vbl_ref_count 00042 { 00043 public: 00044 //: x-coordinate of low point (i == intensity) 00045 float ilow; 00046 00047 //: y-coordinate of low point (p == percentage) 00048 float plow; 00049 00050 //: x-coordinate of high point 00051 float ihigh; 00052 00053 //: y-coordinate of high point 00054 float phigh; 00055 00056 private: 00057 //: Calculated x-coord of y == 0 [low intensity clip point] 00058 float imin_; 00059 00060 //: Calculated x-coord of y == 1 [high intensity clip point] 00061 float imax_; 00062 00063 //: Computed slope of line connecting high & low points 00064 float slope_; 00065 00066 //: Computed y-intercept of line connecting high & low points 00067 float b_; 00068 00069 public: 00070 //: Default constructor 00071 vifa_norm_params(float IntLow = 0.0, 00072 float ProbLow = 0.0, 00073 float IntHigh = 0.0, 00074 float ProbHigh = 0.0 00075 ); 00076 00077 //: Copy constructor 00078 vifa_norm_params(const vifa_norm_params& old_params); 00079 00080 //: Force update of clip points & interpolation line 00081 void recompute(void); 00082 00083 //: Compute normalized equivalent of given intensity 00084 float normalize(float raw_intensity); 00085 00086 //: Find an image's low & high intensities for normalization 00087 static bool get_norm_bounds(vil_image_view_base* img, 00088 float low_bound_pcent, 00089 float high_bound_pcent, 00090 float& normal_low, 00091 float& normal_high 00092 ); 00093 00094 //: Dump the parameters 00095 void print_info(void); 00096 00097 private: 00098 //: Internal method to update clip points & interpolation line 00099 void calculate_clip_points(void); 00100 }; 00101 00102 typedef vbl_smart_ptr<vifa_norm_params> vifa_norm_params_sptr; 00103 00104 00105 #endif // VIFA_NORM_PARAMS_H