Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • dariya.kinadinova.etu/ap-kinadinova-dariya
1 result
Select Git revision
Show changes
Commits on Source (4)
...@@ -10,3 +10,6 @@ ...@@ -10,3 +10,6 @@
#### **20/03/24 :** #### **20/03/24 :**
- Work on Block.py and Decouper_Image.py - Work on Block.py and Decouper_Image.py
#### **27/03/24 :**
- I remade functions decouper, added functions list_col and is_col_close. Made functions average_color, divide_blocks to class Block using the functions previously made. Work on Image_Recursive.
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
""" """
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
from color import * from Color import *
from Decouper_Image import *
class Block: class Block:
def __init__(self, image): def __init__(self, image):
...@@ -29,6 +30,20 @@ class Block: ...@@ -29,6 +30,20 @@ class Block:
""" """
colors = liste_col(self.image, (0, 0), (self.width-1, self.height-1)) colors = liste_col(self.image, (0, 0), (self.width-1, self.height-1))
return avg_col(colors) return avg_col(colors)
def divide_blocks(self):
"""à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
allblocks = []
d = decouper(self.image)
for blocks in d:
allblocks.append(Block(blocks))
return allblocks
def is_uniform(self, coordinates: tuple()): def is_uniform(self, coordinates: tuple()):
"""à_remplacer_par_ce_que_fait_la_fonction """à_remplacer_par_ce_que_fait_la_fonction
......
# KINADINOVA Dariya """
# Images récursives :author: dariya kinadinova
:date: 03/2024
"""
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
...@@ -26,7 +29,7 @@ def avg_col(l:list) -> tuple(): ...@@ -26,7 +29,7 @@ def avg_col(l:list) -> tuple():
return (avg1, avg2, avg3) return (avg1, avg2, avg3)
def list_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]: def list_col(im: Image, left_top: tuple(), right_bottom: tuple()) -> list[int]:
"""à_remplacer_par_ce_que_fait_la_fonction """return a list of colors of each pixels in the given space
Précondition : Précondition :
Exemple(s) : Exemple(s) :
......
"""
:author: dariya kinadinova
:date: 03/2024
"""
from PIL import Image, ImageDraw from PIL import Image, ImageDraw
......
"""
:author: dariya kinadinova
:date: 03/2024
"""
import sys
from PIL import Image, ImageDraw
from Color import *
from Decouper_Image import *
from Block import *
def Image_Recursive(image: Image, order: int):
"""à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
im = image.convert('RGB')
b = Block(im)
if order != 0:
allblocks = b.divide_blocks()
allb = [Image_Recursive(b1.image, order -1) for b1 in allblocks]
if all(b1.is_uniform() for b1 in allb):
avg_c = average_color([b1.color for b1 in allb])
new_b = Block(Image.new(image.size, avg_c))
return new_b
else:
# create a block with index or a loop
block_im = Image.new(image.size)
pass
def main():
"""à_remplacer_par_ce_que_fait_la_fonction
Précondition :
Exemple(s) :
$$$
"""
\ No newline at end of file
File moved