def filtro_roberts(image, orientation='vertical ou horizontal'): print("Result dimensions ", image.shape) mascara_vertical = (0, 0, -1, 0, 1, 0, 0, 0, 0) mascara_horizontal = (-1, 0, 0, 0, 1, 0, 0, 0, 0) if orientation == 'vertical': return filtro(image, mascara_vertical, 3.0) elif orientation == 'horizontal': return filtro(image, mascara_horizontal, 3.0) roberts_vertical = filtro(image, mascara_vertical, 3.0) roberts_horizontal = filtro(image, mascara_horizontal, 3.0) return image_add_01(roberts_vertical, roberts_horizontal)
def filtro_prewitt(image, orientation='vertical ou horizontal'): print("Result dimensions ", image.shape) mascara_vertical = (-1, 0, 1, -1, 0, 1, -1, 0, 1) mascara_horizontal = (-1, -1, -1, 0, 0, 0, 1, 1, 1) if orientation == 'vertical': return filtro(image, mascara_vertical, 3.0) elif orientation == 'horizontal': return filtro(image, mascara_horizontal, 3.0) prewitt_vertical = filtro(image, mascara_vertical, 3.0) prewitt_horizontal = filtro(image, mascara_horizontal, 3.0) return image_add_01(prewitt_vertical, prewitt_horizontal)
def filtro_sobel(image, orientation='vertical ou horizontal'): print("Result dimensions ", image.shape) mascara_vertical = (-1, 0, 1, -2, 0, 2, -1, 0, 1) mascara_horizontal = (-1, -2, -1, 0, 0, 0, 1, 2, 1) if orientation == 'vertical': return filtro(image, mascara_vertical, 4.0) elif orientation == 'horizontal': return filtro(image, mascara_horizontal, 4.0) sobel_vertical = filtro(image, mascara_vertical, 4.0) sobel_horizontal = filtro(image, mascara_horizontal, 4.0) return image_add_01(sobel_vertical, sobel_horizontal)
def filtro_isotropico(image, orientation='vertical ou horizontal'): print("Result dimensions ", image.shape) mascara_vertical = (1, 0, -1, 1.4142135623730951, 0, -1.4142135623730951, 1, 0, -1) mascara_horizontal = (-1, -1.4142135623730951, -1, 0, 0, 0, 1, 1.4142135623730951, 1) # div = 1 # div = 1.5 div = 3.414213562 if orientation == 'vertical': return filtro(image, mascara_vertical, div) elif orientation == 'horizontal': return filtro(image, mascara_horizontal, div) isotropico_vertical = filtro(image, mascara_vertical, div) isotropico_horizontal = filtro(image, mascara_horizontal, div) return image_add_01(isotropico_vertical, isotropico_horizontal)
def filtro_isotropico(image): print("Result dimensions ", image.shape) isotropico_vertical = filtro_isotropico_vertical(image) isotropico_horizontal = filtro_isotropico_horizontal(image) return image_add_01(isotropico_vertical, isotropico_horizontal)
def filtro_roberts(image): print("Result dimensions ", image.shape) roberts_vertical = filtro_roberts_vertical(image) roberts_horizontal = filtro_roberts_horizontal(image) return image_add_01(roberts_vertical, roberts_horizontal)
def filtro_prewitt(image): print("Result dimensions ", image.shape) prewitt_vertical = filtro_prewitt_vertical(image) prewitt_horizontal = filtro_prewitt_horizontal(image) return image_add_01(prewitt_vertical, prewitt_horizontal)
def filtro_sobel(image): print("Result dimensions ", image.shape) sobel_vertical = filtro_sobel_vertical(image) sobel_horizontal = filtro_sobel_horizontal(image) return image_add_01(sobel_vertical, sobel_horizontal)