예제 #1
0
def blur_vertical(img):
    perspective_pov = rand.uniform(-0.4, 0.4)
    resize_factor = rand.uniform(0.7, 1.00)
    gaussian_kernel_size = kernel_size_corrector(rand.randint(3, 9))
    gaussian_sd = rand.randint(1, 4)
    motion_blur_kernel_size = kernel_size_corrector(rand.randint(17, 29))
    motion_blur_angle = np.random.normal(
        90, 10) * (-1 if rand.randint(0, 1) == 0 else 1)

    img, original = rs.reshape(resize_factor, perspective_pov, width, height,
                               img)

    img = bl.gaussian_blur(gaussian_kernel_size, gaussian_sd, img)
    img = bl.motion_blur(motion_blur_kernel_size, motion_blur_angle, img)

    return original, img
예제 #2
0
def blur_mild(img):
    perspective_pov = rand.uniform(-0.4, 0.4)
    resize_factor = rand.uniform(0.7, 1.00)
    gaussian_kernel_size = kernel_size_corrector(rand.randint(3, 5))
    gaussian_sd = rand.randint(1, 2)
    motion_blur_kernel_size = kernel_size_corrector(rand.randint(3, 5))
    motion_blur_angle = rand.uniform(0, 360)
    brightness_factor = rand.randint(0, 5)

    img, original = rs.reshape(resize_factor, perspective_pov, width, height,
                               img)

    img = bl.gaussian_blur(gaussian_kernel_size, gaussian_sd, img)
    img = bl.motion_blur(motion_blur_kernel_size, motion_blur_angle, img)
    img = bc.change_brightness(brightness_factor, img)

    return original, img
예제 #3
0
def blur_brightness(img):
    perspective_pov = rand.uniform(-0.4, 0.4)
    resize_factor = rand.uniform(0.7, 1.00)
    gaussian_kernel_size = kernel_size_corrector(rand.randint(3, 21))
    gaussian_sd = rand.randint(3, 9)
    motion_blur_kernel_size = kernel_size_corrector(rand.randint(3, 5))
    motion_blur_angle = rand.uniform(0, 360)

    img, original = rs.reshape(resize_factor, perspective_pov, width, height,
                               img)

    # Rotate and corrupt the corrupted.
    img = bl.gaussian_blur(gaussian_kernel_size, gaussian_sd, img)
    img = bl.motion_blur(motion_blur_kernel_size, motion_blur_angle, img)
    img = bc.change_brightness(rand.randint(50, 100), img)

    return original, img
예제 #4
0
def blur_pixelation(img):
    perspective_pov = rand.uniform(-0.4, 0.4)
    resize_factor = rand.uniform(0.7, 1.00)
    gaussian_kernel_size = kernel_size_corrector(rand.randint(9, 23))
    gaussian_sd = rand.randint(4, 7)
    motion_blur_kernel_size = kernel_size_corrector(rand.randint(3, 5))
    motion_blur_angle = rand.uniform(0, 360)
    pixelation_magnitude = rand.randint(4, 7)

    img, original = rs.reshape(resize_factor, perspective_pov, width, height,
                               img)

    img = bl.gaussian_blur(gaussian_kernel_size, gaussian_sd, img)
    img = bl.motion_blur(motion_blur_kernel_size, motion_blur_angle, img)
    img = bl.pixelate_blur(pixelation_magnitude, img)

    return original, img
예제 #5
0
def blur_main(img):
    gaussian_kernel_size = kernel_size_corrector(rand.randint(3, 7))
    gaussian_sd = rand.randint(1, 5)
    motion_blur_kernel_size = kernel_size_corrector(rand.randint(11, 25))
    motion_blur_angle = rand.uniform(0, 360)
    perspective_pov = 0.5 - np.random.beta(0.5, 0.5)
    resize_factor = rand.uniform(0.8, 1.00)
    contrast_level = rand.randint(1, 20)
    pixelation_magnitude = rand.randint(4, 7)
    brightness_factor = rand.randint(0, 13)

    img, original = rs.reshape(resize_factor, perspective_pov, width, height,
                               img)

    # Rotate and corrupt the corrupted.
    img = bl.gaussian_blur(gaussian_kernel_size, gaussian_sd, img)
    img = bl.motion_blur(motion_blur_kernel_size, motion_blur_angle, img)
    img = bc.change_brightness(brightness_factor, img)
    img = bl.pixelate_blur(pixelation_magnitude, img)
    img = ct.increase_contrast(img, contrast_level)

    return original, img