def apply_laplacian(img): r, g, b = rgb.get_rgb_layers(img) r, r_sharpened = filter.apply_laplacian(r) g, g_sharpened = filter.apply_laplacian(g) b, b_sharpened = filter.apply_laplacian(b) return rgb.merge_rgb_layers(r, g, b), rgb.merge_rgb_layers( r_sharpened, g_sharpened, b_sharpened)
def apply_sepia(img): height, width = util.get_image_dimensions(img) obtained, img = util.get_empty_image_with_same_dimensions(img) r_matrix, g_matrix, b_matrix = rgb.get_rgb_layers(img) for i in range(height): for j in range(width): r, g, b = r_matrix[i][j], g_matrix[i][j], b_matrix[i][j] tr = int(0.393 * r + 0.769 * g + 0.189 * b) tg = int(0.349 * r + 0.686 * g + 0.168 * b) tb = int(0.272 * r + 0.534 * g + 0.131 * b) r = ColorFilter.__normalize_max_value(tr, r) g = ColorFilter.__normalize_max_value(tg, g) b = ColorFilter.__normalize_max_value(tb, b) obtained[i][j] = [r, g, b] return obtained
def apply_arithmetic_mean(img, filter_matrix): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_arithmetic_mean(r, filter_matrix) g = filter.apply_arithmetic_mean(g, filter_matrix) b = filter.apply_arithmetic_mean(b, filter_matrix) return rgb.merge_rgb_layers(r, g, b)
def apply_sobel(img): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_sobel(r) g = filter.apply_sobel(g) b = filter.apply_sobel(b) return rgb.merge_rgb_layers(r, g, b)
def apply_gradient(img, filter_matrix): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_gradient(r, filter_matrix) g = filter.apply_gradient(g, filter_matrix) b = filter.apply_gradient(b, filter_matrix) return rgb.merge_rgb_layers(r, g, b)
def apply_convolution(img, filter_matrix): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_convolution(r, filter_matrix) g = filter.apply_convolution(g, filter_matrix) b = filter.apply_convolution(b, filter_matrix) return rgb.merge_rgb_layers(r, g, b)
def apply_negative(img): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_negative(r) g = filter.apply_negative(g) b = filter.apply_negative(b) return rgb.merge_rgb_layers(r, g, b)
def apply_piecewise_linear(img, coordinates_x, coordinates_y): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_piecewise_linear(r, coordinates_x, coordinates_y) g = filter.apply_piecewise_linear(g, coordinates_x, coordinates_y) b = filter.apply_piecewise_linear(b, coordinates_x, coordinates_y) return rgb.merge_rgb_layers(r, g, b)
def apply_median(img, filter_size): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_median(r, filter_size) g = filter.apply_median(g, filter_size) b = filter.apply_median(b, filter_size) return rgb.merge_rgb_layers(r, g, b)
def apply_histogram_equalization(img): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_histogram_equalization(r) g = filter.apply_histogram_equalization(g) b = filter.apply_histogram_equalization(b) return rgb.merge_rgb_layers(r, g, b)
def draw_histogram(img, img_name): r, g, b = rgb.get_rgb_layers(img) r = filter.draw_histogram(r, img_name + "_red" + ".jpg", "r") g = filter.draw_histogram(g, img_name + "_green" + ".jpg", "g") b = filter.draw_histogram(b, img_name + "_blue" + ".jpg", "b")
def apply_gamma_correction(img, gamma): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_gamma_correction(r, gamma) g = filter.apply_gamma_correction(g, gamma) b = filter.apply_gamma_correction(b, gamma) return rgb.merge_rgb_layers(r, g, b)
def apply_logarithmic(img): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_logarithmic(r) g = filter.apply_logarithmic(g) b = filter.apply_logarithmic(b) return rgb.merge_rgb_layers(r, g, b)
def apply_highboost(img, c, filter_matrix): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_highboost(r, c, filter_matrix) g = filter.apply_highboost(g, c, filter_matrix) b = filter.apply_highboost(b, c, filter_matrix) return rgb.merge_rgb_layers(r, g, b)
def apply_contra_harmonic_mean(img, filter_matrix, q): r, g, b = rgb.get_rgb_layers(img) r = filter.apply_contra_harmonic_mean(r, filter_matrix, q) g = filter.apply_contra_harmonic_mean(g, filter_matrix, q) b = filter.apply_contra_harmonic_mean(b, filter_matrix, q) return rgb.merge_rgb_layers(r, g, b)