Beispiel #1
0
    def __init__(
        self,
        img_fname: str,
        pb_color=image_utils.ANNOT_COLORS["GREEN"],
        width: int = 750,  # Width of the primary window
        height: int = 750,  # Height of the primary window
        minimap_size: int = 400,  # Size of square minimap
    ):
        tk.Tk.__init__(self)
        self.img_fname = img_fname
        img = image_utils.load_img(img_fname)
        self.height, self.width, _channels = img.shape
        self.rgb_color = pb_color
        self.win_width = width
        self.win_height = height
        self.minimap_size = minimap_size

        self.recorded_points = []
        self.tkinter_lines = []
        # List of tuples, each tuple is 4 values decribing a line
        self.pil_draw_queue = []
        self.canvas = tk.Canvas(
            self,
            width=width,
            height=height,
            cursor="cross",
            scrollregion=(0, 0, self.width, self.height),
        )
        self.canvas.grid(row=0, column=0)
        self.hbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
        self.hbar.config(command=self.canvas.xview)
        self.hbar.grid(row=1, column=0, sticky=tk.E + tk.W)

        self.vbar = tk.Scrollbar(self, orient=tk.VERTICAL)
        self.vbar.config(command=self.canvas.yview)
        self.vbar.grid(row=0, column=1, sticky=tk.NE + tk.SE)

        self.canvas.config(xscrollcommand=self.hbar.set, yscrollcommand=self.vbar.set)

        self.img = Image.open(img_fname)
        self.disp_img = ImageTk.PhotoImage(self.img)
        self.canvas.create_image(0, 0, image=self.disp_img, anchor=tk.NW)

        self.canvas.focus_set()
        self.canvas.bind("<B1-Motion>", self.paintbrush)
        self.canvas.bind("<Button-1>", self.initialize_paintbrush)
        self.canvas.bind("<ButtonRelease-1>", self.close_paintbrush)
        self.canvas.bind("<Return>", self.save_mask)
        self.canvas.bind("<s>", self.save_mask)
        self.canvas.bind("<d>", self.clearlast)
        self.canvas.bind("<D>", self.clearall)
        self.canvas.bind("<m>", self.open_minimap)
Beispiel #2
0
import tensorflow as tf
from tensorflow.python.keras import models
import os
import glob
import image_utils as IU

# Define paths
content_path = 'input/content/elon.jpg'
style_path = 'input/style/ironman.jpg'
init_path = 'input/init/512.jpg'
lena = 'input/content/lena_test.png'
lion = 'input/content/lion.jpg'
dog = 'input/content/dog.jpg'

# Load the style and content images
style_img = IU.load_img(style_path)
content_img = IU.load_img(content_path)
generated_img = tf.Variable(content_img)

# Define which layers are to be used for this model. These layers are defined in Section
# 3 of Gatys' paper
content_layers = ['block5_conv2']
style_layers = [
    'block1_conv1', 'block2_conv1', 'block3_conv1', 'block4_conv1',
    'block5_conv1'
]

num_content_layers = len(content_layers)
num_style_layers = len(style_layers)

# MODEL UTILITIES - FUNCTION 1 - VGG19 LAYERS

  #save result
  img.imsave("./result.png",image.numpy()[0])

  #plt.imshow(image.read_value()[0])
  #plt.show()







if __name__=="__main__":
  content_image = image_utils.load_img("./6.jpeg")
  style_image = image_utils.load_img("./4.jpeg")
  train(content_image=content_image,style_image=style_image)
  #
  # plt.subplot(1, 2, 1)
  # image_utils.imshow(content_image, 'Content Image')
  #
  # plt.subplot(1, 2, 2)
  # image_utils.imshow(style_image, 'Style Image')
  #
  # plt.show()

  # x = tf.keras.applications.vgg19.preprocess_input(content_image*255)
  # #print("x:\n",x)
  # x = tf.image.resize(x, (224, 224))
  # #print("x:\n", x)
Beispiel #4
0
 def __getitem__(self, index):
     _input = load_img(os.path.join(self.a_path, self.files[index]))
     _input = self.transform(_input)
     _target = load_img(os.path.join(self.b_path, self.files[index]))
     _target = self.transform(_target)
     return _input, _target
import cv2 as cv  # type: ignore
import numpy
import numpy.typing

import corner_finder
import edge_finder
import image_utils


def find_boxes(sudoku_img: numpy.typing.NDArray) -> "tuple[int, int]":
    # TODO: Add functionality to detect boundaries of a sudoku box
    edges = edge_finder.get_image_edges(sudoku_img)
    corners = corner_finder.find_harris_corners(edges)
    edge = corner_finder.find_intersections(edges)

    # image_utils.show_image(edges, "edges")
    # image_utils.show_image(corners, "corners")
    # image_utils.show_image(edge, "intersection")
    cv.waitKey(0)

    return (0, 0)


image_path = image_utils.get_image_path("solved_1.png", use_solved_folder=True)
sudoku_image = image_utils.load_img(image_path)
find_boxes(sudoku_image)