Skip to content
Snippets Groups Projects
Commit ec7c71a1 authored by Louis Chmielewski's avatar Louis Chmielewski
Browse files

logiciel_lcom.py charger_image

parent 7f0ceec6
Branches
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
......@@ -10,9 +10,9 @@
"""
from PIL import Image, ImageDraw
from bloc import Bloc
from bloc import *
def decoupe_image(image: Bloc, ordre: int) -> Bloc:
def decoupe_image(bloc: Bloc, ordre: int) -> Bloc:
"""
Decoupe un bloc en quatre bloc "ordre" fois
Précondition :
......@@ -20,12 +20,6 @@ def decoupe_image(image: Bloc, ordre: int) -> Bloc:
$$$
"""
# image = Image.open(image)
# x = ?
# y = ?
# if 0 <= x < largeur and 0 <= y < hauteur:
# pixel = image.getpixel((x, y))
#
# if ordre != 0:
\ No newline at end of file
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
:mod:`fonctions` module : logiciel en ligne de commande
:author: Louis Chmielewski
:date: 2024 mars
"""
import sys
import argparse
import numpy as np
from PIL import *
def charger_image(chemin_fichier: str):
"""
Charger une image depuis un fichier PNG ou CSV
Précondition :
Exemple(s) :
$$$
"""
if chemin_fichier.endswith('.png'):
im = Image.open(chemin_fichier)
return im.show()
elif chemin_fichier.endswith('.csv'):
return np.loadtxt(chemin_fichier, delimiter=',', dtype=np.uint8)
else:
raise ValueError("Format de fichier non pris en charge.")
......@@ -87,7 +87,6 @@ class Bloc:
$$$
"""
return \n
bloc1 = pixel_hl = image.getpixel((0, 0)) and \n
pixel_lr = image.getpixel((largeur/2, hauteur/2)) \n
bloc2 = pixel_hl = image.getpixel((largeur/2, 0)) and \n
......@@ -96,6 +95,7 @@ class Bloc:
pixel_lr = image.getpixel((largeur/2, hauteur)) \n
bloc4 = pixel_hl = image.getpixel((largeur/2, hauteur/2)) and \n
pixel_lr = image.getpixel((largeur, hauteur))
return [bloc1, bloc2, bloc3, bloc4]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment