Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion trdg/background_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ def quasicrystal(height, width):
"""
Create a background with quasicrystal (https://en.wikipedia.org/wiki/Quasicrystal)
"""

image = Image.new("L", (width, height))
pixels = image.load()

frequency = rnd.random() * 30 + 20 # frequency
phase = rnd.random() * 2 * math.pi # phase
rotation_count = rnd.randint(10, 20) # of rotations

if width == 1 or height == 1:
return image.convert("RGBA")

for kw in range(width):
y = float(kw) / (width - 1) * 4 * math.pi - 2 * math.pi
Expand Down
2 changes: 2 additions & 0 deletions trdg/data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def generate(
(new_width, size - vertical_margin), Image.ANTIALIAS
)
resized_mask = distorted_mask.resize((new_width, size - vertical_margin), Image.NEAREST)
if new_width + horizontal_margin <= 0:
horizontal_margin = 1 - new_width
background_width = width if width > 0 else new_width + horizontal_margin
background_height = size
# Vertical text
Expand Down
13 changes: 13 additions & 0 deletions trdg/object_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import random as rnd

from PIL import Image, ImageColor, ImageFont, ImageDraw, ImageFilter


def generate(
imagePath
):
_img = Image.open(imagePath)
_mask = Image.new("RGB", (_img.width, _img.height), (0, 0, 0))


return _img, _mask
Loading