I have a logo. What I am doing now is I am setting probability weights for all of these functions and the logo goes to only one of them at a time depending on its probability value. This is my code:
augmentation_func = [(random_rotation, [brand_logo]),
(blurring, [brand_logo]),
(compression, [brand_logo]),
(portion_covering, [brand_logo, brand_logo_width, brand_logo_height]),
(perspective_transform, [logo_image, brand_logo_width, brand_logo_height]),
(overlaying, [logo_path]),
(logo_background, [logo_path])]
(augs, args), = random.choices(augmentation_func, weights=[10,5,15,20,20,15,15])
new_logo = random_resize(augs(*args), gameplay)
However, this isn't sufficient. The logo should be able to go through multiple functions. For example. A logo could potentially go through random_rotation()
, perspective_transformation()
and overlaying()
. Whether it will go through a function or not should depend on its probability weight. This is my idea:
How can I adjust my code so that the logo goes through many transformation functions depending on the weights?
Is the chance that each operation occurs independent of the others? Then random.choice()
is not the correct solution, since it chooses only one item. Rather, for each item, choose it with its corresponding probability. For example:
if random.randrange(0, 100) < 10:
# Crop the image (in place) at a 10% chance.
# The chance of cropping is independent
# of the chances of any other operation.
brand_logo = cropping(brand_logo)
if random.randrange(0, 100) < 15:
# Rotate the image (in place) at a 15% chance.
# The chance of rotating is independent
# of the chances of any other operation.
brand_logo = rotating(brand_logo)