-
-
Save parzibyte/38f706ac7d136e941a84ea03e58d9d6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
https://parzibyte.me/blog | |
""" | |
import numpy as np | |
import imageio | |
NOMBRE_IMAGEN = "travel.bmp" | |
def leer_imagen(ruta): | |
return np.array(imageio.imread(ruta), dtype='int').tolist() | |
def guardar_imagen(ruta, matriz): | |
return imageio.imwrite(ruta, np.array(matriz, dtype="uint8")) | |
def reflejo_horizontal(nombre_imagen): | |
matriz = leer_imagen(nombre_imagen) | |
ancho = len(matriz[0]) | |
alto = len(matriz) | |
for y in range(alto): | |
for x in range(int(ancho/2)): | |
indice_opuesto = ancho - x - 1 | |
opuesto = matriz[y][indice_opuesto] | |
actual = matriz[y][x] | |
matriz[y][indice_opuesto] = actual | |
matriz[y][x] = opuesto | |
return matriz | |
guardar_imagen("travel_reflejo.bmp", reflejo_horizontal(NOMBRE_IMAGEN)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment