void GUI::mirror(Controller &controller, char sens) { if ( ! controller.image_file_loaded ) { return ; } switch (sens) { case 'l' : mirror_vertical_left(controller.current_image_to_process, controller.current_image_to_process) ; break ; case 'r' : mirror_vertical_right(controller.current_image_to_process, controller.current_image_to_process) ; break ; case 't' : mirror_horizontal_top(controller.current_image_to_process, controller.current_image_to_process) ; break ; case 'b' : mirror_horizontal_bottom(controller.current_image_to_process, controller.current_image_to_process) ; break ; } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying() ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::rotating(Controller &controller, bool sens) { if ( ! controller.image_file_loaded ) { return ; } if (! sens) { rotate_90_left(controller.current_image_to_process, controller.current_image_to_process) ; } else { rotate_90_right(controller.current_image_to_process, controller.current_image_to_process) ; } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying() ; controller.get_current_image_position() ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). set_label_size_value(controller.source_image_size.first, controller.source_image_size.second) ; // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::kernel_mean_callback(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } string kernel_type ; switch (controller.kernel_mean_kernel_type) { case 0 : kernel_type = "rect" ; break ; case 1 : kernel_type = "diamond" ; break ; case 2 : kernel_type = "cross" ; break ; case 3 : kernel_type = "X" ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Cannot identify kernel type !!!\n") ; return ; #endif } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; Mean kernel(controller.kernel_mean_kernel_size, kernel_type) ; kernel.kernel_print() ; kernel.apply(tmp, frame) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::apply_grayscale(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } // Transform image into a grayscale image according choosen settings: switch (combo_current_grayscaling) { case 0 : grayscale(controller.current_image_to_process, controller.current_image_to_process, "average") ; break ; case 1 : grayscale(controller.current_image_to_process, controller.current_image_to_process, "max") ; break ; case 2 : grayscale(controller.current_image_to_process, controller.current_image_to_process, "min") ; break ; case 3 : grayscale(controller.current_image_to_process, controller.current_image_to_process, "red") ; break ; case 4 : grayscale(controller.current_image_to_process, controller.current_image_to_process, "green") ; break ; case 5 : grayscale(controller.current_image_to_process, controller.current_image_to_process, "blue") ; break ; #ifdef DEBUG default : // Cannot append due of the GUI interfacing. fprintf(stdout,"Error applying grayscale filter !!!\n") ; return ; #endif } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying() ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::flip(Controller &controller, char sens) { if ( ! controller.image_file_loaded ) { return ; } static char flip_x_pos = ' ' ; static char flip_y_pos = ' ' ; switch (sens) { case 'l' : if (flip_x_pos != 'l') { flipping(controller.current_image_to_process, controller.current_image_to_process, -1) ; flip_x_pos = 'l' ; } break ; case 'r' : if ( flip_x_pos != ' ' && flip_x_pos != 'r' ) { flipping(controller.current_image_to_process, controller.current_image_to_process, -1) ; flip_x_pos = 'r' ; } break ; case 'u' : if (flip_y_pos != 'u') { flipping(controller.current_image_to_process, controller.current_image_to_process, 1) ; flip_y_pos = 'u' ; } break ; case 'd' : if ( flip_y_pos != ' ' && flip_y_pos != 'd') { flipping(controller.current_image_to_process, controller.current_image_to_process, 1) ; flip_y_pos='d' ; } break ; } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying() ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
int main(int ac, char **av) { t_rt *rt; char *scene; rt = NULL; scene = NULL; if (ac > 1) scene = read_file(av[1]); init_rt(&rt, scene); set_img(&(rt->img), rt->env->img, &(rt->lay)); mlx_expose_hook(rt->env->win, expose_hook, (void*)rt); mlx_loop_hook(rt->env->mlx, loop_hook, (void*)rt); mlx_key_hook(rt->env->win, key_hook, (void*)rt); mlx_loop(rt->env->mlx); return (0); }
inline const typename boost::enable_if<is_expression<Expression>, typename boost::enable_if_c<Expression::dimCount == dimCount, expression_t >::type >::type& operator=(const Expression& expr) const { const dim_t& size = expr.size(); for (unsigned i = 0; i < dimCount; ++i) { tbblas_assert(size[i] == this->size()[i]); } tbblas::detail::for_each( typename tbblas::detail::select_system<cuda_enabled && Expression::cuda_enabled>::system(), thrust::make_zip_iterator(thrust::make_tuple(this->expr.begin(), expr.begin())), thrust::make_zip_iterator(thrust::make_tuple(this->expr.end(), expr.end())), set_img()); return *this; }
void GUI::get_display_area_size(Gtk::Allocation &scr, Controller &controller) { auto container_size = controller.get_layout_size() ; display_area_width=scr.get_width() ; display_area_height=scr.get_height() ; if (container_size.first == display_area_width && container_size.second == display_area_height) { // If nothing changed we return. display_area_size_changed = false ; return ; } display_area_size_changed = true ; controller.set_layout_size(scr.get_width(), scr.get_height()) ; int width, height ; get_size(width, height) ; controller.set_window_size(width, height) ; have_layout_size = true ; if ( widget_current_image_to_display != NULL ) { // Updating current image sizes and positions values. controller.get_current_image_position() ; if ( controller.get_image_size_gt_layout() || controller.get_image_lt_layout() ) { set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). return ; } // Set image at right position. display_area.move(*widget_current_image_to_display, controller.current_image_position.first, controller.current_image_position.second) ; } }
void GUI::zoom_plus(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } cv::Mat frame ; zoom(controller.current_image_to_process, frame, cv::Point2f(controller.mouse_zoom_center_x, controller.mouse_zoom_center_y ), controller.zoom_factor_plus) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). controller.zoom_idx = controller.image_to_display_vector_idx ; controller.zoom_counter++ ; }
void GUI::redo_callback(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } if (controller.image_to_display_vector_idx < controller.image_to_display_vector.size()-1 ) { controller.image_to_display_vector_idx++ ; controller.current_image_to_process = controller.image_to_display_vector.at(controller.image_to_display_vector_idx) ; controller.get_current_image_position() ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). if (controller.image_to_display_vector_idx == controller.image_to_display_vector.size()-1 ) { controller.has_undo = false ; } } }
void GUI::set_image_in_color_tone_callback(Controller &controller, const uint8_t red, const uint8_t green, const uint8_t blue) { if ( ! controller.image_file_loaded ) { return ; } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; set_image_in_color_tone(tmp, frame, red, green, blue) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::mult_global_intensity_callback(Controller &controller, const float factor) { if ( ! controller.image_file_loaded ) { return ; } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; multiply_global_intensity(tmp, frame, factor) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::mult_colors_callback(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; mult_colors(tmp, frame, static_cast<float>(controller.mult_red), static_cast<float>(controller.mult_green), static_cast<float>(controller.mult_blue), static_cast<float>(controller.mult_alpha) ) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::kernel_emboss_callback(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; Emboss kernel(controller.kernel_emboss_kernel_size, controller.kernel_emboss_kernel_values_factor, '+', controller.kernel_emboss_kernel_center_factor) ; kernel.apply(tmp, frame) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::zoom_minus(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } if (controller.zoom_counter > 0) { controller.zoom_idx-- ; controller.zoom_counter-- ; cv::Mat frame = controller.image_to_display_vector.at(controller.zoom_idx) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). } }
void GUI::kernel_kirsch_callback(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } string kernel_direction ; switch (controller.kernel_kirsch_kernel_direction) { case 0 : kernel_direction = "E" ; break ; case 1 : kernel_direction = "W" ; break ; case 2 : kernel_direction = "N" ; break ; case 3 : kernel_direction = "S" ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Cannot identify kernel type !!!\n") ; return ; #endif } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; if (tmp.channels() == 4) { cv::Mat frame_rgb ; cv::Mat tmp_1 ; cvtColor(tmp, frame_rgb, cv::COLOR_BGRA2BGR) ; Kirsch kernel(controller.kernel_kirsch_kernel_size, kernel_direction, controller.kernel_kirsch_kernel_values_factor) ; kernel.apply(frame_rgb, tmp_1) ; vector<cv::Mat> tmp_2 ; vector<cv::Mat> tmp_3 ; cv::split(tmp, tmp_2) ; cv::split(tmp_1, tmp_3) ; // Assign BGR channels. tmp_2[0] = tmp_3[0] ; tmp_2[1] = tmp_3[1] ; tmp_2[2] = tmp_3[2] ; // Final channels merging into result with alpha channel unchanged. cv::merge(tmp_2, frame) ; } else { Kirsch kernel(controller.kernel_kirsch_kernel_size, kernel_direction, controller.kernel_kirsch_kernel_values_factor) ; kernel.apply(tmp, frame) ; } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::process_change_intensity(Controller &controller, uint8_t selected_scale) { if ( ! controller.image_file_loaded ) { return ; } int64_t value = static_cast<int64_t>(get_scale(selected_scale).get_value()) ; bool add = true ; if (value == 0) { return ; } if (value < 0) { value = -value ; add = false ; } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; switch (selected_scale) { case 1 : // Red intensity change ; change_intensity(tmp, frame, add, static_cast<int>(value), 0, 0 ) ; break ; case 2 : // Green intensity change ; change_intensity(tmp, frame, add, 0, static_cast<int>(value), 0 ) ; break ; case 3 : // Blue intensity change ; change_intensity(tmp, frame, add, 0, 0, static_cast<int>(value) ) ; break ; case 4 : // Global intensity change change_intensity(tmp, frame, add, static_cast<int>(value), static_cast<int>(value), static_cast<int>(value) ) ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Error intensity changing\n") ; return ; #endif } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::apply_filter_from_menu(Controller &controller, Gtk::ImageMenuItem &imagemenuitem) { if ( ! controller.image_file_loaded ) { return ; } bool is_alpha = controller.current_image_to_process.channels() == 4 ; Sharpen sharpen_filter(3, "diamond") ; Sharpen sharpen_filter_more(3, "diamond") ; Find_Edges find_edges_filter(3) ; Mean mean_filter(3) ; Mean mean_filter_more(5) ; cv::Mat kernel = make_kernel("rect", 3) ; cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; switch ( stoi(imagemenuitem.get_name()) ) { case 0 : // Pencil Sketch filter. pencil_sketch_filter(tmp, frame) ; break ; case 1 : // Stylisation filter. stylisation_filter(tmp, frame) ; break ; case 2 : // Detail Enhance filter. detail_enhance_filter(tmp, frame) ; break ; case 3 : // Edge Preserving filter. edge_preserving_filter(tmp, frame) ; break ; case 4 : // Stroke edges filter: stroke_edges(tmp, frame) ; break ; case 5 : // Invert Intensity filter: invert_intensity(tmp, frame) ; break ; case 6 : // Light Intensity filter: effect_light(tmp, frame) ; break ; case 7 : // Recolor-RC (Red-Cyan) filter: recolorRC(tmp, frame) ; break ; case 8 : // Recolor-RC (Red-Green-Value) filter: recolorRGV(tmp, frame) ; break ; case 9 : // Recolor-RC (Cyan-Magenta-Value) filter: recolorCMV(tmp, frame) ; break ; case 10 : // Extrema Maximal Filter: extrema(tmp, frame, "max") ; break ; case 11 : // Extrema Minimal Filter: extrema(tmp, frame, "min") ; break ; case 12 : // Sharpen filter: sharpen_filter.apply(tmp, frame) ; break ; case 13 : // Sharpen More filter: sharpen_filter_more.apply(tmp, frame) ; break ; case 14 : // Find Edges filter: if (is_alpha) { cv::Mat frame_rgb ; cv::Mat tmp_1 ; cvtColor(tmp, frame_rgb, cv::COLOR_BGRA2BGR) ; find_edges_filter.apply(frame_rgb, tmp_1) ; vector<cv::Mat> tmp_2 ; vector<cv::Mat> tmp_3 ; cv::split(tmp, tmp_2) ; cv::split(tmp_1, tmp_3) ; // Assign BGR channels. tmp_2[0] = tmp_3[0] ; tmp_2[1] = tmp_3[1] ; tmp_2[2] = tmp_3[2] ; // Final channels merging into result with alpha channel unchanged. cv::merge(tmp_2, frame) ; break ; } find_edges_filter.apply(tmp, frame) ; break ; case 15 : // Mean Blur filter: mean_filter.apply(tmp, frame) ; break ; case 16 : // Mean Blur More filter: mean_filter_more.apply(tmp, frame) ; break ; case 17 : // Blur filter: blur_filter(tmp, frame) ; break ; case 18 : // Median Blur filter: median_blur_filter(tmp, frame) ; break ; case 19 : // Gaussian Blur filter: gaussian_blur_filter(tmp, frame) ; break ; case 20 : denoising_filter(tmp, frame) ; break ; case 21 : // Erode filter: erode_filter(tmp, frame, kernel, 1) ; break ; case 22 : // Dilate filter: dilate_filter(tmp, frame, kernel, 1) ; break ; case 23 : // Wave Horizontally filter: wave(tmp, frame, -1) ; break ; case 24 : // Wave Vertically filter: wave(tmp, frame, 1) ; break ; case 25 : // Wave Twice (Horizontally and Vertically) filter: wave(tmp, frame, 0) ; break ; case 26 : // Contours Sobel White filter. sobel_drawning(tmp, frame, 3, false, 1) ; break ; case 27 : // Contours Sobel Black filter. sobel_drawning(tmp, frame, 3, false, -1) ; break ; case 28 : // Contours Sobel Emboss filter. sobel_drawning(tmp, frame, 3, false, 0) ; break ; case 29 : // Emboss Sobel filter: sobel_emboss(tmp, frame, 3) ; break ; case 30 : // Emboss Laplacian filter: laplacian_emboss(tmp, frame, 3) ; break ; case 31 : // Binary White OTSU filter: // Build a binary image (a black and white only image) with white background (@arg value true) // based on the OTSU threshold computing algorithm (@arg value -1). build_binary_image(tmp, frame, -1, true) ; break ; case 32 : // Binary White TRIANGLE filter: // Build a binary image (a black and white only image) with white background (@arg value true) // based on the TRIANGLE threshold computing algorithm (@arg value 1). build_binary_image(tmp, frame, 1, true) ; break ; case 33 : // Binary White AVERAGE filter: // Build a binary image (a black and white only image) with white background (@arg value true) // based on the AVERAGE threshold from OTSU and TRIANGLE (@arg value 0). build_binary_image(tmp, frame, 0, true) ; break ; case 34 : // Binary Black OTSU filter: // Build a binary image (a black and white only image) with black background (@arg value true) // based on the OTSU threshold computing algorithm (@arg value -1). build_binary_image(tmp, frame, -1, false) ; break ; case 35 : // Binary Black TRIANGLE filter: // Build a binary image (a black and white only image) with black background (@arg value true) // based on the TRIANGLE threshold computing algorithm (@arg value 1). build_binary_image(tmp, frame, 1, false) ; break ; case 36 : // Binary Black AVERAGE filter: // Build a binary image (a black and white only image) with black background (@arg value true) // based on the AVERAGE threshold from OTSU and TRIANGLE (@arg value 0). build_binary_image(tmp, frame, 0, false) ; break ; case 37 : // Binary Contours White filter: // Build a binary image (a black and white only image) with contours detction on white background (@arg value false). laplacian_zero_crossing(tmp, frame, 19, false) ; break ; case 38 : // Binary Contours Black filter: // Build a binary image (a black and white only image) with contours detction on black background (@arg value true). laplacian_zero_crossing(tmp, frame, 19, true) ; break ; #ifdef DEBUG default : // Cannot append due of the GUI interfacing. fprintf(stdout,"Error applying filter !!!\n") ; return ; #endif } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::process_change_colorspace(Controller &controller, uint8_t selected_scale) { if ( ! controller.image_file_loaded ) { return ; } long int value = static_cast<long int>(get_scale(selected_scale).get_value()) ; if (value == 0) { return ; } const float div = (selected_scale == 9) ? 2.0f : (selected_scale == 7) ? 1.0 : 16.0f ; const float factor = (1.0f / (255.0f / div )) * static_cast<double>(value) ; cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; switch (selected_scale) { case 6 : // Lightness change ; change_lightness(tmp, frame, factor) ; break ; case 7 : // Hue change ; change_hue(tmp, frame, factor) ; break ; case 8 : // Saturation change ; change_saturation(tmp, frame, factor) ; break ; case 9 : // Brightness change ; change_brightness(tmp, frame, factor) ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Error Change HSBL settings\n") ; return ; #endif } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::morphological_callback(Controller &controller) { if ( ! controller.image_file_loaded ) { return ; } string kernel_type ; switch (controller.morphological_kernel_type) { case 0 : kernel_type = "rect" ; break ; case 1 : kernel_type = "diamond" ; break ; case 2 : kernel_type = "cross" ; break ; case 3 : kernel_type = "X" ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Cannot identify kernel type !!!\n") ; return ; #endif } char center_value ; switch (controller.morphological_center_value) { case 0 : center_value = '1' ; break ; case 1 : center_value = '0' ; break ; case 2 : center_value = '+' ; break ; case 3 : center_value = '-' ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Cannot identify center value !!!\n") ; return ; #endif } int operator_type ; switch (controller.morphological_operator_type) { case 0 : operator_type = cv::MORPH_ERODE ; break ; case 1 : operator_type = cv::MORPH_DILATE ; break ; case 2 : operator_type = cv::MORPH_OPEN ; break ; case 3 : operator_type = cv::MORPH_CLOSE ; break ; case 4 : operator_type = cv::MORPH_TOPHAT ; break ; case 5 : operator_type = cv::MORPH_BLACKHAT ; break ; #ifdef DEBUG default : // This cannot append due of the GUI interfacing. fprintf(stderr,"Cannot identify operator !!!\n") ; return ; #endif } cv::Mat kernel = make_kernel(kernel_type, static_cast<int>(controller.morphological_kernel_size), center_value) ; cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; morphological_filter(tmp, frame, operator_type, kernel, static_cast<int>(controller.morphological_iterations) ) ; // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
void GUI::apply_colorscale_from_menu(Controller &controller, Gtk::ImageMenuItem &imagemenuitem) { if ( ! controller.image_file_loaded ) { return ; } cv::Mat tmp = controller.current_image_to_process.clone() ; cv::Mat frame ; // Apply a colorscale on the image according choosen settings: switch ( stoi(imagemenuitem.get_name()) ) { case 0 : colorscale(tmp, frame, "red", "average") ; break ; case 1 : colorscale(tmp, frame, "red", "max") ; break ; case 2 : colorscale(tmp, frame, "red", "min") ; break ; case 3 : colorscale(tmp, frame, "red", "red") ; break ; case 4 : colorscale(tmp, frame, "red", "green") ; break ; case 5 : colorscale(tmp, frame, "green", "average") ; break ; case 6 : colorscale(tmp, frame, "green", "max") ; break ; case 7 : colorscale(tmp, frame, "green", "min") ; break ; case 8 : colorscale(tmp, frame, "green", "red") ; break ; case 9 : colorscale(tmp, frame, "green", "blue") ; break ; case 10 : colorscale(tmp, frame, "blue", "average") ; break ; case 11 : colorscale(tmp, frame, "blue", "max") ; break ; case 12 : colorscale(tmp, frame, "blue", "min") ; break ; case 13 : colorscale(tmp, frame, "blue", "red") ; break ; case 14 : colorscale(tmp, frame, "blue", "green") ; break ; case 15 : colorscale(tmp, frame, "yellow", "average") ; break ; case 16 : colorscale(tmp, frame, "yellow", "max") ; break ; case 17 : colorscale(tmp, frame, "yellow", "min") ; break ; case 18 : colorscale(tmp, frame, "yellow", "red") ; break ; case 19 : colorscale(tmp, frame, "yellow", "green") ; break ; case 20 : colorscale(tmp, frame, "yellow", "blue") ; break ; case 21 : colorscale(tmp, frame, "pink", "average") ; break ; case 22 : colorscale(tmp, frame, "pink", "max") ; break ; case 23 : colorscale(tmp, frame, "pink", "min") ; break ; case 24 : colorscale(tmp, frame, "pink", "red") ; break ; case 25 : colorscale(tmp, frame, "pink", "green") ; break ; case 26 : colorscale(tmp, frame, "pink", "blue") ; break ; case 27 : colorscale(tmp, frame, "turquoise", "average") ; break ; case 28 : colorscale(tmp, frame, "turquoise", "max") ; break ; case 29 : colorscale(tmp, frame, "turquoise", "min") ; break ; case 30 : colorscale(tmp, frame, "turquoise", "red") ; break ; case 31 : colorscale(tmp, frame, "turquoise", "green") ; break ; case 32 : colorscale(tmp, frame, "turquoise", "blue") ; break ; #ifdef DEBUG default : // Cannot append due of the GUI interfacing. fprintf(stdout,"Error applying colorscale filter !!!\n") ; return ; #endif } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset some variables. after_applying_reset_settings(controller) ; }
bool GUI::on_display_area_button_press_handler(GdkEventButton *event_button, Controller &controller) { if (button_zoom_pointer.get_active() ) { // This is in relationship with the button setting for mouse selection of zoom center. if ( controller.mouse_into_image && controller.mouse_curser_changed == 1 && event_button->button == 1 ) { // Settings the zoom center coordinates by mutiplying the coordinates from inside the image per factors: controller.mouse_zoom_center_x = static_cast<float>(controller.mouse_inside_image_x) * controller.factor_width ; controller.mouse_zoom_center_y = static_cast<float>(controller.mouse_inside_image_y) * controller.factor_height ; controller.process_after_applying() ; // We register current frame in vector<cv::Mat> for undo-redo. // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(controller.current_image_to_process, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). // Reset cursor. main_window_gdk_window->set_cursor() ; // Reset control variables: controller.mouse_curser_changed = -1 ; controller.draw_offset = 0.0 ; if ( button_zoom_pointer.get_active() ) { // If button pressed, raise it. button_zoom_pointer.set_active(false) ; } } else if (event_button->button != 1) { // Reset cursor. main_window_gdk_window->set_cursor() ; controller.reset_zoom_center(controller.current_image_to_process) ; controller.mouse_curser_changed = -1 ; if ( button_zoom_pointer.get_active() ) { // If button pressed, raise it. button_zoom_pointer.set_active(false) ; } } } else if ( button_draw_rect.get_active() || button_draw_line.get_active() || button_draw_circle.get_active() || button_draw_ellipse.get_active() || button_draw_polygon.get_active() || button_draw_star.get_active() || button_draw_text.get_active() ) { if ( controller.mouse_into_image && controller.mouse_curser_changed == 1 && event_button->button == 1 ) { if ( (controller.drawning_status == -1) || (controller.drawning_status == 1) ) { // Getting the drawning coordinates onto the real (not resized) image by multiplying per factors: controller.mouse_draw_x1 = static_cast<float>(controller.mouse_inside_image_x) * controller.factor_width ; controller.mouse_draw_y1 = static_cast<float>(controller.mouse_inside_image_y) * controller.factor_height ; controller.drawning_status = 0 ; controller.saved_frame = controller.current_image_to_process.clone() ; if ( button_draw_line.get_active() ) { goto fake_mouse_1_button_press ; } if ( button_draw_text.get_active() ) { goto fake_mouse_1_button_press ; } return false ; } else if (controller.drawning_status == 0) { fake_mouse_1_button_press : // Getting the drawning coordinates onto the real (not resized) image by multiplying per factors: controller.mouse_draw_x2 = static_cast<float>(controller.mouse_inside_image_x) * controller.factor_width ; controller.mouse_draw_y2 = static_cast<float>(controller.mouse_inside_image_y) * controller.factor_height ; controller.drawning_status = 1 ; cv::Scalar color(draw_color.get_blue_u() >> 8, draw_color.get_green_u() >> 8, draw_color.get_red_u() >> 8, draw_color.get_alpha_u() >> 8) ; cv::Mat frame = controller.current_image_to_process.clone() ; if (button_draw_line.get_active() ) { if ( controller.polylines_points_nb == 0) { controller.polylines_start_rect = cv::Rect( cv::Point(controller.mouse_draw_x1-7, controller.mouse_draw_y1-7), cv::Size(15, 15) ) ; } controller.polylines.push_back( cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1)) ; controller.polylines_points_nb++ ; if ( controller.polylines_points_nb > 1) { if ( controller.polylines_start_rect.contains(cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1)) ) { draw_polylines(frame , controller.polylines, true, (draw_thickness < 0), color, (draw_thickness < 0) ? 0 : draw_thickness , draw_line_type) ; controller.polylines_points_nb = 0 ; controller.polylines.clear() ; controller.polylines.shrink_to_fit() ; } else { draw_polylines(frame , controller.polylines, false, false, color, (draw_thickness < 0) ? 0 : draw_thickness, draw_line_type) ; } } } else if (button_draw_rect.get_active()) { cv::Rect rect( cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), cv::Point(controller.mouse_draw_x2, controller.mouse_draw_y2) ) ; draw_rect(frame, rect, color, draw_thickness, draw_line_type) ; } else if (button_draw_circle.get_active() ) { const int radius = static_cast<int>(roundf( sqrtf(powf(static_cast<float>(controller.mouse_draw_x2)-static_cast<float>(controller.mouse_draw_x1), 2) + powf(static_cast<float>(controller.mouse_draw_y2)-static_cast<float>(controller.mouse_draw_y1), 2))) ) ; draw_circle(frame, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), radius, color, draw_thickness, draw_line_type) ; } else if (button_draw_ellipse.get_active() ) { const int distance_x = abs(controller.mouse_draw_x1-controller.mouse_draw_x2) ; const int distance_y = abs(controller.mouse_draw_y1-controller.mouse_draw_y2) ; const cv::RotatedRect rot_rect(cv::Point2f( static_cast<float>(controller.mouse_draw_x1), static_cast<float>(controller.mouse_draw_y1) ), cv::Size(abs( distance_x * 2 ), abs( distance_y * 2 ) ), 0.0 ) ; draw_ellipse(frame, rot_rect, color, draw_thickness, draw_line_type) ; } else if (button_draw_polygon.get_active() && controller.config_draw_success == Gtk::RESPONSE_OK ) { const double radius = round( sqrt (pow(static_cast<double>(controller.mouse_draw_x2)-static_cast<double>(controller.mouse_draw_x1), 2) + pow(static_cast<double>(controller.mouse_draw_y2)-static_cast<double>(controller.mouse_draw_y1), 2)) ) ; vector<cv::Point> polygon ; double offset_correct = 0.0 ; if ((controller.polygon_edges > 4) && (controller.polygon_edges % 2 == 1)) { offset_correct = 360.0 / controller.polygon_edges / 2.0 / 2.0 ; } bool fill = false ; if ( ! controller.polygon_strikethrough && draw_thickness < 0 ) { fill = true ; } generate_polygon(controller.polygon_edges, radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), polygon, controller.polygon_strikethrough, false, controller.polygon_offset + controller.draw_offset + offset_correct) ; draw_polylines(frame, polygon, true, fill, color, ((draw_thickness < 0) ? 0 : draw_thickness) , draw_line_type) ; } else if (button_draw_text.get_active() && controller.config_draw_success == Gtk::RESPONSE_OK ) { int italic_flags = (controller.put_text_is_italic) ? cv::FONT_ITALIC : 0 ; draw_text(frame, controller.put_text_string, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), controller.put_text_font_face | italic_flags, controller.put_text_font_scale, color, ((draw_thickness < 0) ? 0 : draw_thickness), draw_line_type) ; controller.drawning_status = 1 ; } else if (button_draw_star.get_active() && controller.config_draw_success == Gtk::RESPONSE_OK ) { const double radius = round( sqrt (pow(static_cast<double>(controller.mouse_draw_x2)-static_cast<double>(controller.mouse_draw_x1), 2) + pow(static_cast<double>(controller.mouse_draw_y2)-static_cast<double>(controller.mouse_draw_y1), 2)) ) ; vector<cv::Point> star ; bool join_stroke = true ; bool fill = false ; if ( controller.star_correcting && (! controller.star_strokes) && (controller.star_pikes == 5 || controller.star_pikes == 6) ) { if ( ! controller.star_flower && ! controller.star_strikethrough && draw_thickness < 0 ) { fill = true ; } switch (controller.star_pikes) { case 5 : generate_pentagram(radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, controller.star_strikethrough, controller.star_flower, (360.0 / 5.0 / 2.0 / 2.0) + controller.star_offset + controller.draw_offset ) ; break ; case 6 : generate_hexagram(radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, controller.star_strikethrough, controller.star_flower, controller.star_offset + controller.draw_offset ) ; break ; } } else if ( ! controller.star_strokes) { if ( ! controller.star_flower && ! controller.star_strikethrough && ! controller.star_strokes && draw_thickness < 0 ) { fill = true ; } generate_star(controller.star_pikes , radius , cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, controller.star_strikethrough, controller.star_flower, controller.star_offset + controller.draw_offset + ((controller.star_pikes == 5) ? (360.0 / 5.0 / 2.0 / 2.0) : 0) ) ; } else { generate_polygon(controller.star_pikes, radius, cv::Point(controller.mouse_draw_x1, controller.mouse_draw_y1), star, false, true, controller.star_offset + controller.draw_offset ) ; join_stroke = false ; } draw_polylines(frame, star, join_stroke, fill, color, ((draw_thickness < 0) ? 0 : draw_thickness), draw_line_type) ; } // We register current frame in vector<cv::Mat> for undo-redo. controller.process_after_applying(frame) ; // It convert current_image_to_process as src to RGB(A) in dst current_image_to_display. set_img(frame, controller.current_image_to_display, controller) ; // It auto process conversion to RGB(A). frame.release() ; controller.saved_frame.release() ; controller.mouse_curser_changed = -1 ; return false ; } } else if (event_button->button == 3) {
void set_img_chinese(enemy *e, char *img, int dx){ set_img(e, C_PREFIX, img, dx); }