egami
C++ Image Processing program
|
00001 #include <memory> 00002 #include <algorithm> 00003 #include <string> 00004 #include <vector> 00005 00006 #include <gtkmm/image.h> 00007 #include <gtkmm/dialog.h> 00008 #include <gtkmm/spinbutton.h> 00009 #include <gtkmm/label.h> 00010 #include <gtkmm/enums.h> 00011 #include <gtkmm/stock.h> 00012 00013 #include "../display_unit.hpp" 00014 #include "../processing_page.hpp" 00015 #include "../processing_unit.hpp" 00016 #include "../utils.hpp" 00017 #include "../progress.hpp" 00018 #include "order_statistic.hpp" 00019 00020 namespace{ 00021 class Config: public Gtk::Dialog { 00022 public: 00023 Config(int m): adj(Gtk::Adjustment::create(1, 1, m, 1, 5)), tt("Radius:"), bt(adj), rad(0) { 00024 set_resizable(false); 00025 00026 get_vbox()->pack_start(tt); 00027 get_vbox()->pack_start(bt); 00028 00029 add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); 00030 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); 00031 00032 show_all_children(); 00033 } 00034 00035 unsigned radius(){ 00036 rad=rad?rad:bt.get_value(); 00037 return rad; 00038 } 00039 private: 00040 Glib::RefPtr<Gtk::Adjustment> adj; 00041 Gtk::Label tt; 00042 Gtk::SpinButton bt; 00043 unsigned rad; 00044 }; 00045 00046 Display_unit *impl(const Image_unit *in){ 00047 Config config(std::max(in->width(), in->height())); 00048 if(config.run()!=Gtk::RESPONSE_OK) 00049 return nullptr; 00050 config.hide(); 00051 00052 return apply_order_statistic(in, config.radius(), [](const std::vector<unsigned char> &v) -> unsigned char { return v.front(); }); 00053 } 00054 } 00055 00056 namespace Processes{ 00057 void min_filter(){ 00058 Gtk::Image icon(cmake_install_prefix+std::string("/share/egami/icons/min_filter.png")); 00059 std::shared_ptr<Processing_unit> pu(new Processing_unit(Processing(&impl), "Min filter", icon, false)); 00060 Processing_page::add_unit_to_page("Order statistic", pu); 00061 } 00062 }