Go to the documentation of this file.00001
00002 #ifndef bgui_image_utils_h_
00003 #define bgui_image_utils_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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 #include <vsol/vsol_polygon_2d_sptr.h>
00022 class bgui_image_utils
00023 {
00024 public:
00025
00026 bgui_image_utils();
00027
00028 bgui_image_utils(vil_image_resource_sptr const& image,
00029 vsol_polygon_2d_sptr const& poly = 0);
00030
00031 ~bgui_image_utils(){}
00032
00033
00034 void set_image(vil_image_resource_sptr const& image);
00035 void set_poly(vsol_polygon_2d_sptr const& poly);
00036
00037 void set_bin_limit( unsigned bin_limit){ bin_limit_ = bin_limit;}
00038 void set_n_skip_upper_bins(unsigned n_skip){n_skip_upper_bins_=n_skip;}
00039 void set_n_skip_lower_bins(unsigned n_skip){n_skip_lower_bins_=n_skip;}
00040 void set_percent_limit(double limit){percent_limit_ = limit;}
00041 void set_min_blocks(unsigned min_blocks){min_blocks_ = min_blocks;}
00042 void set_scan_fraction(double scan_fraction){scan_fraction_ = scan_fraction;}
00043
00044 bool range(double& min_value, double& max_value, unsigned plane = 0);
00045 bsta_histogram<double> histogram(unsigned plane = 0)
00046 { if (!hist_valid_)this->construct_histogram(); return hist_[plane]; }
00047 bgui_graph_tableau_sptr hist_graph();
00048
00049
00050 bool default_range_map(vgui_range_map_params_sptr& rmp,
00051 double gamma = 1.0, bool invert = false,
00052 bool gl_map = false, bool cache=true);
00053
00054
00055 bool range_map_from_hist(float gamma, bool invert,
00056 bool gl_map, bool cache,
00057 vgui_range_map_params_sptr& rmp);
00058
00059 private:
00060
00061
00062 bool init_histogram_from_data();
00063
00064 bool set_data_from_view(vil_image_view_base_sptr const& view,
00065 double fraction = 1.0);
00066
00067 bool set_data_by_random_blocks(const unsigned total_num_blocks,
00068 vil_blocked_image_resource_sptr const& bir,
00069 double fraction = 1.0);
00070 bool set_data_inside_polygon(vil_blocked_image_resource_sptr const& bir);
00071
00072 bool construct_histogram();
00073 double compute_lower_bound(unsigned plane = 0);
00074 double compute_upper_bound(unsigned plane = 0);
00075
00076
00077 bool hist_valid_;
00078 double percent_limit_;
00079 unsigned bin_limit_;
00080 unsigned n_skip_upper_bins_;
00081 unsigned n_skip_lower_bins_;
00082 unsigned min_blocks_;
00083 double scan_fraction_;
00084
00085 vil_image_resource_sptr image_;
00086 vsol_polygon_2d_sptr poly_;
00087 vcl_vector<bsta_histogram<double> > hist_;
00088 vcl_vector<vcl_vector<double> > data_;
00089 };
00090
00091
00092 #endif // bgui_image_utils_h_