Ejemplo n.º 1
0
    def next_image(self, image: ImageWrapper) -> ImageWrapper:
        self.dimensions = image.dimensions()
        self.channels = image.channels

        if self.theta1 is None:
            self.get_avg_color()

        self.iterate()

        image_copy = image.copy()
        image_copy.channels = self.get_channels_with_borders()
        image_copy.draw_image()

        return image_copy
Ejemplo n.º 2
0
def canny_border_detection_wrapper(image: ImageWrapper.ImageWrapper,
                                   gauss_sigma, t1,
                                   t2) -> ImageWrapper.ImageWrapper:
    img: Image = image.image_element

    # Applying gaussian filter
    img = channel_gaussian_window(img, gauss_sigma)

    # Magnitude and slope
    gx, gy = directional_derivatives(
        ImageWrapper.ImageWrapper(img).channels[0])

    g = np.hypot(gx, gy)

    g_max = g.max()
    g_min = g.min()

    g_w, g_h = g.shape

    for x in range(g_w):
        for y in range(g_h):
            g[x, y] = (g[x, y] - g_min) * 255 / (g_max - g_min)

    slope = discrete_slope(
        np.array([val * 180 / np.pi for val in np.arctan2(gy, gx)]))

    channel = maximum_suppression(g, slope)

    borders = mark_borders(t2, channel)

    borders = weak_borders(t1, borders, channel)

    channel = clean_image_with_borders(borders, channel)

    image_copy = image.copy()
    image_copy.channels = [channel]

    return image_copy