contrib/brl/bbas/bgui/bgui_image_utils.h

Go to the documentation of this file.
00001 // This is brl/bbas/bgui/bgui_image_utils.h
00002 #ifndef bgui_image_utils_h_
00003 #define bgui_image_utils_h_
00004 //:
00005 // \file
00006 // \author  Joseph Mundy
00007 // \brief Utilities for computing image properties used in display
00008 // Currently only implemented for unsigned grey scale images,
00009 //  i.e., uchar, ushort, uint.
00010 // \verbatim
00011 //  Modifications
00012 //   JLM   Sept. 28, 2006  Initial version.
00013 // \endverbatim
00014 
00015 #include <vil/vil_image_view_base.h>
00016 #include <vil/vil_image_resource.h>
00017 #include <vil/vil_blocked_image_resource_sptr.h>
00018 #include <bsta/bsta_histogram.h>
00019 #include <bgui/bgui_graph_tableau.h>
00020 #include <vgui/vgui_range_map_params_sptr.h>
00021 class bgui_image_utils
00022 {
00023  public:
00024   //:constructors
00025   bgui_image_utils();
00026 
00027   bgui_image_utils(vil_image_resource_sptr const& image);
00028 
00029   ~bgui_image_utils(){}
00030 
00031   //: Set the image on which properties are computed
00032   void set_image(vil_image_resource_sptr const& image);
00033 
00034   void set_bin_limit( unsigned bin_limit){ bin_limit_ = bin_limit;}
00035   void set_n_skip_upper_bins(unsigned n_skip){n_skip_upper_bins_=n_skip;}
00036   void set_n_skip_lower_bins(unsigned n_skip){n_skip_lower_bins_=n_skip;}
00037   void set_percent_limit(double limit){percent_limit_ = limit;}
00038   void set_min_blocks(unsigned min_blocks){min_blocks_ = min_blocks;}
00039   void set_scan_fraction(double scan_fraction){scan_fraction_ = scan_fraction;}
00040 
00041   bool range(double& min_value, double& max_value, unsigned plane = 0);
00042   bsta_histogram<double> histogram(unsigned plane = 0)
00043   { if (!hist_valid_)this->construct_histogram(); return hist_[plane]; }
00044   bgui_graph_tableau_sptr hist_graph();
00045 
00046   //: Default range map based on default max min values
00047   bool default_range_map(vgui_range_map_params_sptr& rmp,
00048                          double gamma = 1.0, bool invert = false, 
00049                          bool gl_map = false, bool cache=true);
00050 
00051   //: Range map computed from the image histogram
00052   bool range_map_from_hist(float gamma, bool invert,
00053                            bool gl_map, bool cache,
00054                            vgui_range_map_params_sptr& rmp);
00055 
00056  private:
00057   //private utilities
00058 
00059   bool init_histogram_from_data();
00060 
00061   bool set_data_from_view(vil_image_view_base_sptr const& view,
00062                           double fraction = 1.0);
00063 
00064   bool set_data_by_random_blocks(const unsigned total_num_blocks,
00065                                  vil_blocked_image_resource_sptr const& bir,
00066                                  double fraction = 1.0);
00067   bool construct_histogram();
00068   double compute_lower_bound(unsigned plane = 0);
00069   double compute_upper_bound(unsigned plane = 0);
00070   //members
00071 
00072   bool hist_valid_;
00073   double percent_limit_;
00074   unsigned bin_limit_;
00075   unsigned n_skip_upper_bins_;
00076   unsigned n_skip_lower_bins_;
00077   unsigned min_blocks_;
00078   double scan_fraction_;
00079 
00080   vil_image_resource_sptr image_;
00081   vcl_vector<bsta_histogram<double> > hist_;
00082   vcl_vector<vcl_vector<double> > data_;
00083 };
00084 
00085 
00086 #endif // bgui_image_utils_h_

Generated on Thu Nov 20 05:22:07 2008 for contrib/brl/bbas/bgui by  doxygen 1.5.1