示例#1
0
def generate_color_fading_input():
    interface = InterfaceInfo.get_instance()
    interface.reset_parameters()
    ttk.Label(interface.buttons_frame,
              text="Image width",
              background=constants.TOP_COLOR).grid(row=0, column=0)
    ttk.Label(interface.buttons_frame,
              text="Image height",
              background=constants.TOP_COLOR).grid(row=1, column=0)
    red = BooleanVar()
    green = BooleanVar()
    blue = BooleanVar()
    Checkbutton(interface.buttons_frame,
                text="Red",
                variable=red,
                background=constants.TOP_COLOR).grid(row=2, column=0)
    Checkbutton(interface.buttons_frame,
                text="Green",
                variable=green,
                background=constants.TOP_COLOR).grid(row=2, column=1)
    Checkbutton(interface.buttons_frame,
                text="Blue",
                variable=blue,
                background=constants.TOP_COLOR).grid(row=2, column=2)
    image_width = Entry(interface.buttons_frame)
    image_height = Entry(interface.buttons_frame)
    image_width.grid(row=0, column=1)
    image_height.grid(row=1, column=1)
    generate_gray_fading_button = ttk.Button(
        interface.buttons_frame,
        text="Show",
        command=lambda: color_faded_image(int(image_width.get(
        )), int(image_height.get()), red.get(), green.get(), blue.get()))
    generate_gray_fading_button.grid(row=3, column=0)
def border_enhancement_filter_wrapper(image, width, height):
    interface = InterfaceInfo.get_instance()
    interface.delete_widgets(interface.buttons_frame)
    if image is None:
        messagebox.showerror(title="Error", message="You need to upload an image to get its negative")
    else:
        border_enhancement_filter(image, width, height)
示例#3
0
def generate_rectangle_input():
    interface = InterfaceInfo.get_instance()
    interface.clean_images()
    interface.delete_widgets(interface.buttons_frame)
    interface.delete_widgets(interface.image_frame)
    ttk.Label(interface.buttons_frame, text="Rectangle width", background=constants.TOP_COLOR).grid(row=0, column=0)
    ttk.Label(interface.buttons_frame, text="Rectangle height", background=constants.TOP_COLOR).grid(row=1, column=0)
    ttk.Label(interface.buttons_frame, text="Image width", background=constants.TOP_COLOR).grid(row=0, column=2)
    ttk.Label(interface.buttons_frame, text="Image height", background=constants.TOP_COLOR).grid(row=1, column=2)
    width = Entry(interface.buttons_frame)
    height = Entry(interface.buttons_frame)
    image_width = Entry(interface.buttons_frame)
    image_height = Entry(interface.buttons_frame)
    radio_var = BooleanVar()
    radio_var.set(True)
    Radiobutton(interface.buttons_frame, text="Empty", value=False, variable=radio_var,
                background=constants.TOP_COLOR).grid(row=1, column=4)
    Radiobutton(interface.buttons_frame, text="Filled", value=True, variable=radio_var,
                background=constants.TOP_COLOR).grid(row=0, column=4)
    width.grid(row=0, column=1)
    height.grid(row=1, column=1)
    image_width.grid(row=0, column=3)
    image_height.grid(row=1, column=3)
    draw_pixel_button = ttk.Button(interface.buttons_frame, text="Draw",
                                   command=lambda: generate_rectangle("rectangle.png", int(image_width.get()),
                                                                      int(image_height.get()), int(width.get()),
                                                                      int(height.get()), radio_var.get()))
    # TODO validate params
    draw_pixel_button.grid(row=3, column=0)
示例#4
0
 def __init__(self, menubar):
     interface = InterfaceInfo.get_instance()
     function_menu = Menu(menubar, tearoff=0)
     menubar.add_cascade(label="Function", menu=function_menu)
     function_menu.add_command(label="Gamma", command=generate_gamma_input)
     function_menu.add_command(label="Dynamic Range Compression",
                               command=generate_range_compression_input)
     threshold_menu = Menu(function_menu, tearoff=0)
     function_menu.add_cascade(label="Threshold", menu=threshold_menu)
     threshold_menu.add_command(label="Custom",
                                command=generate_image_threshold_input)
     threshold_menu.add_command(label="Global",
                                command=lambda: global_threshold_wrapper(
                                    interface.current_image, constants.
                                    HEIGHT, constants.WIDTH, interface))
     otsu_menu = Menu(function_menu, tearoff=0)
     threshold_menu.add_cascade(label="Otsu", menu=otsu_menu)
     otsu_menu.add_command(label="B&W",
                           command=lambda: otsu_threshold_wrapper(
                               interface.current_image, constants.HEIGHT,
                               constants.WIDTH, interface))
     otsu_menu.add_command(
         label="RGB",
         command=lambda: otsu_threshold_with_color_wrapper(
             interface.current_image, constants.HEIGHT, constants.WIDTH,
             interface))
     function_menu.add_command(label="Equalization",
                               command=lambda: equalized_image_wrapper(
                                   interface.current_image, constants.WIDTH,
                                   constants.HEIGHT, interface))
     function_menu.add_command(label="Grey Histogram",
                               command=lambda: grey_level_histogram_wrapper(
                                   interface.current_image, constants.WIDTH,
                                   constants.HEIGHT, interface))
示例#5
0
def generate_copy_sub_image_input():
    interface = InterfaceInfo.get_instance()
    generate_binary_operations_input(interface)
    ttk.Label(interface.buttons_frame, text="Original image", background=constants.TOP_COLOR).grid(row=1, column=0)
    ttk.Label(interface.buttons_frame, text="X", background=constants.TOP_COLOR).grid(row=2, column=0)
    ttk.Label(interface.buttons_frame, text="Y", background=constants.TOP_COLOR).grid(row=3, column=0)
    ttk.Label(interface.buttons_frame, text="Width", background=constants.TOP_COLOR).grid(row=2, column=2)
    ttk.Label(interface.buttons_frame, text="Height", background=constants.TOP_COLOR).grid(row=3, column=2)
    ttk.Label(interface.buttons_frame, text="Image to copy", background=constants.TOP_COLOR).grid(row=1, column=4)
    ttk.Label(interface.buttons_frame, text="X", background=constants.TOP_COLOR).grid(row=2, column=4)
    ttk.Label(interface.buttons_frame, text="Y", background=constants.TOP_COLOR).grid(row=3, column=4)
    x_original = Entry(interface.buttons_frame)
    y_original = Entry(interface.buttons_frame)
    width_original = Entry(interface.buttons_frame)
    height_original = Entry(interface.buttons_frame)
    x_copy = Entry(interface.buttons_frame)
    y_copy = Entry(interface.buttons_frame)
    x_original.grid(row=2, column=1)
    y_original.grid(row=3, column=1)
    width_original.grid(row=2, column=3)
    height_original.grid(row=3, column=3)
    x_copy.grid(row=2, column=5)
    y_copy.grid(row=3, column=5)
    modify_pixel_button = ttk.Button(interface.buttons_frame, text="Copy",
                                     command=lambda: copy_pixels_wrapper(int(x_original.get()),
                                                                 int(y_original.get()),int(width_original.get()),
                                                                 int(height_original.get()), int(x_copy.get()) - 1,
                                                                 int(y_copy.get()),interface.left_image,
                                                                 interface.right_image))
    #TODO validate cast
    modify_pixel_button.grid(row=4, column=0)
def generate_canny_color_method_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="Sigma S", background=constants.TOP_COLOR).grid(row=0, column=0)
        sigma_s = Entry(interface.buttons_frame)
        sigma_s.grid(row=0, column=1)
        ttk.Label(interface.buttons_frame, text="Sigma R", background=constants.TOP_COLOR).grid(row=1, column=0)
        sigma_r = Entry(interface.buttons_frame)
        sigma_r.grid(row=1, column=1)
        ttk.Label(interface.buttons_frame, text="Windows size", background=constants.TOP_COLOR).grid(row=0, column=2)
        windows_size = Entry(interface.buttons_frame)
        windows_size.grid(row=0, column=3)
        radio_var = BooleanVar()
        radio_var.set(True)
        Radiobutton(interface.buttons_frame, text="Four neighbours", value=True,
                    variable=radio_var, background=constants.TOP_COLOR).grid(row=0, column=4)
        Radiobutton(interface.buttons_frame, text="Eight neighbours", value=False,
                    variable=radio_var, background=constants.TOP_COLOR).grid(row=1, column=4)
        apply_method = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: colored_canny_method(interface.current_image, constants.HEIGHT,
                                                               constants.WIDTH, int(sigma_s.get()), int(sigma_r.get()),
                                                               int(windows_size.get()), radio_var.get()))
        apply_method.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply canny method")
def generate_laplacian_gaussian_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="Sigma", background=constants.TOP_COLOR).grid(row=0, column=0)
        ttk.Label(interface.buttons_frame, text="Threshold", background=constants.TOP_COLOR).grid(row=0, column=2)
        sigma = Entry(interface.buttons_frame)
        threshold = Entry(interface.buttons_frame)
        sigma.grid(row=0, column=1)
        threshold.grid(row=0, column=3)
        radio_var = StringVar()
        radio_var.set("or")
        Radiobutton(interface.buttons_frame, text="And", value="and",
                    variable=radio_var, background=constants.TOP_COLOR).grid(row=1, column=0)
        Radiobutton(interface.buttons_frame, text="Or", value="or",
                    variable=radio_var, background=constants.TOP_COLOR).grid(row=1, column=1)
        Radiobutton(interface.buttons_frame, text="Module", value="module",
                    variable=radio_var, background=constants.TOP_COLOR).grid(row=1, column=2)
        apply_filter = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: laplacian_gaussian_method(interface.current_image,
                                                                            constants.HEIGHT, constants.WIDTH,
                                                                            float(sigma.get()), int(threshold.get()),
                                                                            radio_var.get()))
        apply_filter.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply laplacian gaussian")
 def __init__(self, menubar):
     interface = InterfaceInfo.get_instance()
     border_detection_menu = Menu(menubar, tearoff=0)
     menubar.add_cascade(label="Border detection", menu=border_detection_menu)
     border_detection_menu.add_command(label="Border enhancement",
                                       command=lambda: border_enhancement_filter_wrapper(interface.current_image,
                                                                                         constants.WIDTH,
                                                                                         constants.HEIGHT))
     prewit_menu = Menu(border_detection_menu, tearoff=0)
     border_detection_menu.add_cascade(label="Prewitt", menu=prewit_menu)
     prewit_menu.add_command(label="Grey", command=prewit_detection_wrapper)
     prewit_menu.add_command(label="Color", command=prewit_color_detection_wrapper)
     sobel_menu = Menu(border_detection_menu, tearoff=0)
     border_detection_menu.add_cascade(label="Sobel", menu=sobel_menu)
     sobel_menu.add_command(label="Grey", command=sobel_detection_wrapper)
     sobel_menu.add_command(label="Color", command=sobel_color_detection_wrapper)
     border_detection_menu.add_command(label="Four directions", command=generate_four_direction_input)
     border_detection_menu.add_command(label="Laplacian", command=generate_laplacian_input)
     border_detection_menu.add_command(label="Laplacian with slope", command=generate_laplacian_with_slope_input)
     border_detection_menu.add_command(label="Laplacian Gaussian", command=generate_laplacian_gaussian_input)
     canny_menu = Menu(border_detection_menu, tearoff=0)
     border_detection_menu.add_cascade(label="Canny", menu=canny_menu)
     canny_menu.add_command(label="Grey", command=generate_canny_method_input)
     canny_menu.add_command(label="Color", command=generate_canny_color_method_input)
     border_detection_menu.add_command(label="Susan Detector", command=generate_susan_method_input)
     sift_menu = Menu(border_detection_menu, tearoff=0)
     border_detection_menu.add_cascade(label="Sift Comparison", menu=sift_menu)
     sift_menu.add_command(label="Grey", command=generate_sift_method_wrapper)
     sift_menu.add_command(label="Color", command=generate_colored_sift_method_wrapper)
     harris_menu = Menu(border_detection_menu, tearoff=0)
     border_detection_menu.add_cascade(label="Harris", menu=harris_menu)
     harris_menu.add_command(label="Grey", command=generate_harris_method_input)
     harris_menu.add_command(label="Color", command=generate_colored_harris_method_input)
 def __init__(self):
     interface = InterfaceInfo.get_instance()
     root = interface.get_root()
     interface.configure()
     interface.load_frames()
     self.load_footer_buttons(interface)
     self.load_menu(root)
示例#10
0
def generate_multiply_images_operation_input():
    interface = InterfaceInfo.get_instance()
    generate_binary_operations_input(interface)
    multiply_button = ttk.Button(interface.buttons_frame, text="Multiply",
                                 command=lambda: multiply_grey_images_wrapper(constants.WIDTH, constants.HEIGHT,
                                                                              interface.left_image, constants.WIDTH,
                                                                              constants.HEIGHT, interface.right_image))
    multiply_button.grid(row=1, column=0)
示例#11
0
 def __init__(self, menubar):
     interface = InterfaceInfo.get_instance()
     image_menu = Menu(menubar, tearoff=0)
     menubar.add_cascade(label="Image", menu=image_menu)
     image_menu.add_command(label="Open", command=load_image_wrapper)
     image_menu.add_command(label="Save", command=save_image)
     image_menu.add_separator()
     image_menu.add_command(label="Exit", command=interface.root.quit)
示例#12
0
def generate_subtract_grey_operation_input():
    interface = InterfaceInfo.get_instance()
    generate_binary_operations_input(interface)
    subtract_button = ttk.Button(interface.buttons_frame, text="Subtract",
                                 command=lambda: subtract_grey_image_wrapper(constants.WIDTH, constants.HEIGHT,
                                                                             interface.left_image,
                                                                             interface.right_image))
    subtract_button.grid(row=1, column=0)
示例#13
0
def generate_range_compression_input():
    interface = InterfaceInfo.get_instance()
    interface.delete_widgets(interface.buttons_frame)
    if interface.current_image is not None:
        dynamic_range_compression(interface.current_image, constants.WIDTH,
                                  constants.HEIGHT)
    else:
        messagebox.showerror(
            title="Error",
            message="You must upload an image to generate range compression")
示例#14
0
def save_image():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is None:
        messagebox.showerror(title="Error", message="You must upload an image to save it")
    else:
        image = interface.current_image
        image_info = image.filename = asksaveasfilename(initialdir="/", title="Select file", filetypes=(
            ('ppm', '*.ppm'), ('jpg', '*.jpg'), ('jpeg', '*.jpeg'), ('png', '*.png'),  ("pgm", "*.pgm")))
        image.convert("I")
        image.save(image_info)
 def __init__(self, menubar):
     interface = InterfaceInfo.get_instance()
     filters_menu = Menu(menubar, tearoff=0)
     menubar.add_cascade(label="Filters", menu=filters_menu)
     filters_menu.add_command(label="Media", command=generate_media_filter_input)
     filters_menu.add_command(label="Median", command=generate_median_filter_input)
     filters_menu.add_command(label="Weighted median",
                              command=lambda: weighted_median_wrapper(interface.current_image, constants.WIDTH,
                                                                      constants.HEIGHT))
     filters_menu.add_command(label="Gaussian", command=generate_gaussian_filter_input)
     filters_menu.add_command(label="Bilateral", command=generate_bilateral_filter_input)
     filters_menu.add_command(label="Isotropic diffusion", command=generate_isotropic_diffusion_filter_input)
     filters_menu.add_command(label="Anisotropic diffusion", command=generate_anisotropic_diffusion_filter_input)
示例#16
0
def load_image_wrapper():
    interface = InterfaceInfo.get_instance()
    interface.remove_images()
    if interface.current_image is None:
        interface.current_image = load_image(0, 0)
        # harris_method(interface.current_image, constants.HEIGHT, constants.WIDTH, 0.8)
        # sift_method(interface.current_image, constants.HEIGHT, constants.WIDTH)
        # compare_images(interface.current_image, constants.HEIGHT, constants.WIDTH, interface.current_image, constants.HEIGHT, constants.WIDTH, 400)
    elif interface.image_to_copy is None:
        interface.image_to_copy = load_image(0, 1)
    else:
        messagebox.showerror(title="Error", message="You can't upload more than two images. If you want to change"
                                                    " one click on the \"Clean image\" button first")
def generate_media_filter_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="Windows size", background=constants.TOP_COLOR).grid(row=0, column=0)
        windows_size = Entry(interface.buttons_frame)
        windows_size.grid(row=0, column=1)
        generate_noise = ttk.Button(interface.buttons_frame, text="Apply",
                                    command=lambda: media_filter(interface.current_image, constants.WIDTH,
                                                                 constants.HEIGHT, int(windows_size.get())))
        generate_noise.grid(row=1, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply media filter")
def generate_susan_method_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="T difference", background=constants.TOP_COLOR).grid(row=0, column=0)
        t_difference = Entry(interface.buttons_frame)
        t_difference.grid(row=0, column=1)
        apply_method = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: susan_method(interface.current_image, constants.HEIGHT,
                                                               constants.WIDTH, int(t_difference.get())))
        apply_method.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply susan method")
def generate_harris_method_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="Threshold", background=constants.TOP_COLOR).grid(row=0, column=0)
        threshold = Entry(interface.buttons_frame)
        threshold.grid(row=0, column=1)
        apply_filter = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: harris_method(interface.current_image, constants.HEIGHT,
                                                                constants.WIDTH, float(threshold.get()), False))
        apply_filter.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply harris method")
def generate_isotropic_diffusion_filter_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="T max", background=constants.TOP_COLOR).grid(row=0, column=0)
        t_max = Entry(interface.buttons_frame)
        t_max.grid(row=0, column=1)
        apply_filter = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: isotropic_diffusion_filter(interface.current_image,
                                                                               constants.WIDTH, constants.HEIGHT,
                                                                               int(t_max.get())))
        apply_filter.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply isotropic diffusion filter")
示例#21
0
def generate_multiply_by_scalar_input():
    interface = InterfaceInfo.get_instance()
    interface.reset_parameters()
    load_image_button = ttk.Button(interface.buttons_frame, text="Load Image",
                                   command=lambda: load_left_image(interface))
    load_image_button.grid(row=0, column=0)
    ttk.Label(interface.buttons_frame, text="Scalar", background=constants.TOP_COLOR).grid(row=1, column=0)
    scalar = Entry(interface.buttons_frame)
    scalar.grid(row=1, column=1)
    multiply_button = ttk.Button(interface.buttons_frame, text="Multiply",
                                 command=lambda: multiply_grey_images_with_scalar_wrapper(constants.WIDTH,
                                                                                          constants.HEIGHT,
                                                                                          interface.left_image,
                                                                                          scalar.get()))
    multiply_button.grid(row=2, column=0)
def generate_get_pixel_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="X", background=constants.TOP_COLOR).grid(row=0, column=0)
        ttk.Label(interface.buttons_frame, text="Y", background=constants.TOP_COLOR).grid(row=1, column=0)
        x = Entry(interface.buttons_frame)
        y = Entry(interface.buttons_frame)
        x.grid(row=0, column=1)
        y.grid(row=1, column=1)
        get_pixel_button = ttk.Button(interface.buttons_frame,
                                      text="Get Value",
                                      command=lambda: get_pixel_value(interface, x.get(), y.get()))
        get_pixel_button.grid(row=2, column=0)
    else:
        messagebox.showerror(title="Error", message="You must upload an image to get the value of a pixel")
    def __init__(self):
        if Region.__instance is not None:
            raise Exception("This class is a singleton!")
        else:
            interface = InterfaceInfo.get_instance()
            self.canvas = interface.canvas
            self.current_image = interface.current_image
            self.x = self.y = 0
            self.canvas.bind("<ButtonPress-1>", self.on_button_press)
            self.canvas.bind("<B1-Motion>", self.on_move_press)
            self.canvas.bind("<ButtonRelease-1>", self.on_button_release)

            self.rect = None
            self.end_x = None
            self.end_y = None
            self.start_x = None
            self.start_y = None
def generate_line_circle_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="Threshold", background=constants.TOP_COLOR).grid(row=0, column=0)
        threshold = Entry(interface.buttons_frame)
        threshold.grid(row=0, column=1)
        ttk.Label(interface.buttons_frame, text="Epsilon", background=constants.TOP_COLOR).grid(row=1, column=0)
        epsilon = Entry(interface.buttons_frame)
        epsilon.grid(row=1, column=1)
        apply_method = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: hough_transform(interface.current_image, constants.HEIGHT,
                                                                           constants.WIDTH, int(threshold.get()),
                                                                           float(epsilon.get())))
        apply_method.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(title="Error", message="You must upload an image to apply hough")
示例#25
0
def generate_gamma_input():
    interface = InterfaceInfo.get_instance()
    interface.delete_widgets(interface.buttons_frame)
    if interface.current_image is not None:
        ttk.Label(interface.buttons_frame,
                  text="Gamma",
                  background=constants.TOP_COLOR).grid(row=0, column=0)
        gamma = Entry(interface.buttons_frame)
        gamma.grid(row=0, column=1)
        apply_button = ttk.Button(interface.buttons_frame,
                                  text="Apply",
                                  command=lambda: gamma_pow_function_wrapper(
                                      interface.current_image, constants.WIDTH,
                                      constants.HEIGHT, gamma.get()))
        apply_button.grid(row=1, column=0)
    else:
        messagebox.showerror(title="Error",
                             message="You must upload an image to apply gamma")
def generate_gaussian_noise_input():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is not None:
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame,
                  text="Percentage",
                  background=constants.TOP_COLOR).grid(row=0, column=3)
        ttk.Label(interface.buttons_frame,
                  text="Mu",
                  background=constants.TOP_COLOR).grid(row=0, column=0)
        ttk.Label(interface.buttons_frame,
                  text="Sigma",
                  background=constants.TOP_COLOR).grid(row=1, column=0)
        percentage = Entry(interface.buttons_frame)
        mu = Entry(interface.buttons_frame)
        sigma = Entry(interface.buttons_frame)
        percentage.grid(row=0, column=4)
        mu.grid(row=0, column=2)
        sigma.grid(row=1, column=2)
        radio_var = BooleanVar()
        radio_var.set(True)
        Radiobutton(interface.buttons_frame,
                    text="Additive",
                    value=True,
                    variable=radio_var,
                    background=constants.TOP_COLOR).grid(row=0, column=5)
        Radiobutton(interface.buttons_frame,
                    text="Multiplicative",
                    value=False,
                    variable=radio_var,
                    background=constants.TOP_COLOR).grid(row=1, column=5)
        generate_noise = ttk.Button(
            interface.buttons_frame,
            text="Generate",
            command=lambda: gaussian_noise_generator(
                float(percentage.get()), radio_var.get(
                ), interface.current_image, constants.WIDTH, constants.HEIGHT,
                int(mu.get()), float(sigma.get())))
        generate_noise.grid(row=2, column=0)
    else:
        interface.reset_parameters()
        messagebox.showerror(
            title="Error",
            message="You must upload an image to generate gaussian noise")
示例#27
0
def generate_gray_fading_input():
    interface = InterfaceInfo.get_instance()
    interface.reset_parameters()
    ttk.Label(interface.buttons_frame,
              text="Image width",
              background=constants.TOP_COLOR).grid(row=0, column=0)
    ttk.Label(interface.buttons_frame,
              text="Image height",
              background=constants.TOP_COLOR).grid(row=1, column=0)
    image_width = Entry(interface.buttons_frame)
    image_height = Entry(interface.buttons_frame)
    image_width.grid(row=0, column=1)
    image_height.grid(row=1, column=1)
    generate_gray_fading_button = ttk.Button(
        interface.buttons_frame,
        text="Show",
        command=lambda: gray_faded_image(int(image_width.get()),
                                         int(image_height.get())))
    generate_gray_fading_button.grid(row=3, column=0)
def pixel_exchange_color_wrapper():
    interface = InterfaceInfo.get_instance()
    if interface.current_image is None:
        messagebox.showerror(title="Error", message="You must upload an image to mark a region")
    else:
        interface.delete_widgets(interface.buttons_frame)
        region = Region()
        interface.delete_widgets(interface.buttons_frame)
        ttk.Label(interface.buttons_frame, text="Epsilon", background=constants.TOP_COLOR).grid(row=0, column=0)
        epsilon = Entry(interface.buttons_frame)
        epsilon.grid(row=0, column=1)
        ttk.Label(interface.buttons_frame, text="Max iterations", background=constants.TOP_COLOR).grid(row=1, column=0)
        max_iterations = Entry(interface.buttons_frame)
        max_iterations.grid(row=1, column=1)
        apply_filter = ttk.Button(interface.buttons_frame, text="Apply",
                                  command=lambda: generate_pixel_exchange_color_input(interface, region,
                                                                                      float(epsilon.get()),
                                                                                     int(max_iterations.get())))
        apply_filter.grid(row=2, column=0)
示例#29
0
 def __init__(self, menubar):
     interface = InterfaceInfo.get_instance()
     operation_menu = Menu(menubar, tearoff=0)
     menubar.add_cascade(label="Operations", menu=operation_menu)
     operation_menu.add_command(label="Add", command=generate_add_operation_input)
     subtract_menu = Menu(operation_menu, tearoff=0)
     operation_menu.add_cascade(label="Subtract", menu=subtract_menu)
     subtract_menu.add_command(label="Color", command=generate_subtract_colored_operation_input)
     subtract_menu.add_command(label="B&W", command=generate_subtract_grey_operation_input)
     multiply_menu = Menu(operation_menu, tearoff=0)
     operation_menu.add_cascade(label="Multiply", menu=multiply_menu)
     multiply_menu.add_command(label="By scalar", command=generate_multiply_by_scalar_input)
     multiply_menu.add_command(label="Two images", command=generate_multiply_images_operation_input)
     operation_menu.add_command(label="Copy", command=generate_copy_sub_image_input)
     negative_menu = Menu(operation_menu, tearoff=0)
     operation_menu.add_cascade(label="Negative", menu=negative_menu)
     negative_menu.add_command(label="Colored Negative", command=lambda:
                               colored_negative_wrapper(interface.current_image, constants.WIDTH, constants.HEIGHT))
     negative_menu.add_command(label="Grey Negative", command=lambda:
                               grey_negative_wrapper(interface.current_image, constants.WIDTH, constants.HEIGHT))
示例#30
0
def generate_image_threshold_input():
    interface = InterfaceInfo.get_instance()
    interface.delete_widgets(interface.buttons_frame)
    if interface.current_image is not None:
        ttk.Label(interface.buttons_frame,
                  text="Threshold",
                  background=constants.TOP_COLOR).grid(row=0, column=0)
        threshold = Entry(interface.buttons_frame)
        threshold.grid(row=0, column=1)
        apply_threshold = ttk.Button(
            interface.buttons_frame,
            text="Apply",
            command=lambda: image_threshold(interface.current_image, constants.
                                            WIDTH, constants.HEIGHT,
                                            float(threshold.get())))
        apply_threshold.grid(row=1, column=0)
    else:
        messagebox.showerror(
            title="Error",
            message="You must upload an image to apply a threshold")