Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-CHMIELEWSKI-Louis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Louis Chmielewski
AP-CHMIELEWSKI-Louis
Commits
51e10dae
Commit
51e10dae
authored
1 year ago
by
Louis Chmielewski
Browse files
Options
Downloads
Patches
Plain Diff
decoupe_image et modif bloc.py
parent
031b8ce4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Projet/README.md
+6
-0
6 additions, 0 deletions
Projet/README.md
Projet/decoupe_image.py
+15
-9
15 additions, 9 deletions
Projet/decoupe_image.py
Projet/src/bloc.py
+12
-12
12 additions, 12 deletions
Projet/src/bloc.py
with
33 additions
and
21 deletions
Projet/README.md
+
6
−
0
View file @
51e10dae
...
@@ -24,3 +24,9 @@ author : Louis Chmielewski
...
@@ -24,3 +24,9 @@ author : Louis Chmielewski
-
24/03 : petite modification de la méthode init pour la class bloc
-
24/03 : petite modification de la méthode init pour la class bloc
-
24/03 : début réalisation de la fonction découpe_image
-
24/03 : début réalisation de la fonction découpe_image
-
26/03 : création du script de conversion de fichier csv en fichier png
-
26/03 : corrections d'erreurs dans bloc.py
-
26/03 : réalisation de la fonction decoupe_image
This diff is collapsed.
Click to expand it.
Projet/decoupe_image.py
+
15
−
9
View file @
51e10dae
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
"""
"""
from
PIL
import
Image
,
ImageDraw
from
PIL
import
Image
,
ImageDraw
from
bloc
import
Bloc
from
bloc
import
Bloc
import
manip_couleurs
#importer image et recuperer sa taille
#importer image et recuperer sa taille
...
@@ -30,15 +31,20 @@ def decoupe_image(image: Bloc, ordre: int) -> Bloc:
...
@@ -30,15 +31,20 @@ def decoupe_image(image: Bloc, ordre: int) -> Bloc:
"""
"""
image
.
pixel_hl
=
(
0
,
0
)
image
.
pixel_hl
=
(
0
,
0
)
image
.
pixel_lr
=
im
.
size
image
.
pixel_lr
=
im
.
size
# if ordre !=0:
if
ordre
!=
0
:
# en_4_blocs(bloc)
en_4_blocs
(
bloc
)
# decoupe_image(*arg: list[Bloc], ordre-1)
decoupe_image
(
*
arg
:
list
[
Bloc
],
ordre
-
1
)
# if sont_4_blocs_uniformes_proches(bloc1, bloc2, bloc3, bloc4):
if
sont_4_blocs_uniformes_proches
[
bloc1
,
bloc2
,
bloc3
,
bloc4
]:
# # fonction à définir dans la classe bloc
return
new_bloc
=
moyenne_couleur_bloc
(
moyenne_couleur_bloc
(
bloc1
),
\
# else:
moyenne_couleur_bloc
(
bloc2
),
\
# # fonction à définir dans la classe bloc
moyenne_couleur_bloc
(
bloc3
),
\
# else:
moyenne_couleur_bloc
(
bloc4
))
# # fonction à définir dans la classe bloc
else
:
new_bloc
=
[
bloc1
,
bloc2
,
bloc3
,
bloc4
]
return
new_bloc
else
:
new_bloc
=
[
bloc1
,
bloc2
,
bloc3
,
bloc4
]
return
new_bloc
...
...
This diff is collapsed.
Click to expand it.
Projet/src/bloc.py
+
12
−
12
View file @
51e10dae
...
@@ -34,7 +34,7 @@ class Bloc:
...
@@ -34,7 +34,7 @@ class Bloc:
"""
"""
return
self
.
bloc
==
other
.
bloc
return
self
.
bloc
==
other
.
bloc
def
est_bloc_uniforme
(
bloc1
:
Bloc
,
bloc2
:
Bloc
,
bloc3
:
Bloc
,
bloc4
:
Bloc
)
->
bool
:
def
est_bloc_uniforme
(
liste_bloc
:
list
[
Bloc
,
Bloc
,
Bloc
,
Bloc
]
)
->
bool
:
"""
"""
Renvoie True si le bloc est un bloc uniforme, c
'
est à dire si les 4 couleurs du bloc sont proches
Renvoie True si le bloc est un bloc uniforme, c
'
est à dire si les 4 couleurs du bloc sont proches
Précondition : aucune
Précondition : aucune
...
@@ -42,9 +42,9 @@ class Bloc:
...
@@ -42,9 +42,9 @@ class Bloc:
$$$
$$$
"""
"""
return
est_couleur_proche
(
moyenne_couleur_bloc
(
bloc
1
),
moyenne_couleur_bloc
(
bloc
2
))
and
\
return
est_couleur_proche
(
moyenne_couleur_bloc
(
liste_
bloc
[
0
]
),
moyenne_couleur_bloc
(
liste_
bloc
[
1
]
))
and
\
est_couleur_proche
(
moyenne_couleur_bloc
(
bloc
1
),
moyenne_couleur_bloc
(
bloc
3
))
and
\
est_couleur_proche
(
moyenne_couleur_bloc
(
liste_
bloc
[
0
]
),
moyenne_couleur_bloc
(
liste_
bloc
[
2
]
))
and
\
est_couleur_proche
(
moyenne_couleur_bloc
(
bloc
1
),
moyenne_couleur_bloc
(
bloc
4
))
est_couleur_proche
(
moyenne_couleur_bloc
(
liste_
bloc
[
0
]
),
moyenne_couleur_bloc
(
liste_
bloc
[
3
]
))
def
est_bloc_non_uniforme
()
->
bool
:
def
est_bloc_non_uniforme
()
->
bool
:
...
@@ -58,7 +58,7 @@ class Bloc:
...
@@ -58,7 +58,7 @@ class Bloc:
"""
"""
return
not
(
est_bloc_uniforme
())
return
not
(
est_bloc_uniforme
())
def
sont_4_blocs_uniformes_proches
(
bloc
1
:
Bloc
,
bloc2
:
Bloc
,
bloc3
:
Bloc
,
bloc4
:
Bloc
)
->
bool
:
def
sont_4_blocs_uniformes_proches
(
liste_
bloc
:
list
[
Bloc
,
Bloc
,
Bloc
,
Bloc
]
)
->
bool
:
"""
"""
Renvoie True si les 4 blocs uniformes sont proches
Renvoie True si les 4 blocs uniformes sont proches
Précondition : aucune
Précondition : aucune
...
@@ -69,9 +69,8 @@ class Bloc:
...
@@ -69,9 +69,8 @@ class Bloc:
False
False
"""
"""
res
=
False
res
=
False
parametres
=
[
bloc1
,
bloc2
,
bloc3
,
bloc4
]
if
all
(
est_bloc_uniforme
(
liste_bloc
)):
if
all
(
est_bloc_uniforme
(
parametres
)):
for
i
in
range
(
1
,
len
(
liste_bloc
)
-
1
):
for
i
in
parametres
(
1
,
len
(
parametres
)
-
1
):
if
est_couleur_proche
(
bloc1
,
bloc
[
i
]):
if
est_couleur_proche
(
bloc1
,
bloc
[
i
]):
res
=
True
res
=
True
return
res
return
res
...
@@ -86,14 +85,15 @@ class Bloc:
...
@@ -86,14 +85,15 @@ class Bloc:
"""
"""
bloc1
=
pixel_hl
=
image
.
getpixel
((
0
,
0
))
and
\
bloc1
=
pixel_hl
=
image
.
getpixel
((
0
,
0
))
and
\
pixel_lr
=
image
.
getpixel
((
largeur
/
2
,
hauteur
/
2
))
\
pixel_lr
=
image
.
getpixel
((
largeur
/
2
,
hauteur
/
2
))
bloc2
=
pixel_hl
=
image
.
getpixel
((
largeur
/
2
,
0
))
and
\
bloc2
=
pixel_hl
=
image
.
getpixel
((
largeur
/
2
,
0
))
and
\
pixel_lr
=
image
.
getpixel
((
largeur
,
hauteur
/
2
))
\
pixel_lr
=
image
.
getpixel
((
largeur
,
hauteur
/
2
))
bloc3
=
pixel_hl
=
image
.
getpixel
((
0
,
hauteur
/
2
))
and
\
bloc3
=
pixel_hl
=
image
.
getpixel
((
0
,
hauteur
/
2
))
and
\
pixel_lr
=
image
.
getpixel
((
largeur
/
2
,
hauteur
))
\
pixel_lr
=
image
.
getpixel
((
largeur
/
2
,
hauteur
))
bloc4
=
pixel_hl
=
image
.
getpixel
((
largeur
/
2
,
hauteur
/
2
))
and
\
bloc4
=
pixel_hl
=
image
.
getpixel
((
largeur
/
2
,
hauteur
/
2
))
and
\
pixel_lr
=
image
.
getpixel
((
largeur
,
hauteur
))
pixel_lr
=
image
.
getpixel
((
largeur
,
hauteur
))
return
[
bloc1
,
bloc2
,
bloc3
,
bloc4
]
new_bloc
=
[
bloc1
,
bloc2
,
bloc3
,
bloc4
]
return
new_bloc
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment