Created
June 26, 2022 12:56
-
-
Save ManishAradwad/9b68a49f17930f0b88141bab9cb72eff to your computer and use it in GitHub Desktop.
Custom Gradient Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Final function to return some random crease from 8 different types | |
def custom_crease(): | |
spacing = random.uniform(1, 1.5) | |
scale = random.randint(100, 300) | |
corner = random.randint(1, 4) | |
# constant determines the type of crease and also is used to scale spacing in parabolic_crease | |
constant = random.randint(1, 10) | |
# Returning those creases which are based on parabolic | |
parabolic = parabolic_crease(spacing, constant, scale, corner) | |
if constant == 1: | |
return parabolic | |
elif constant == 2: | |
return normalize_img(parabolic*parabolic.T*parabolic[::-1]*parabolic.T[::-1]) | |
# Returning those creases which are based on parabolic and cross | |
cross = cross_crease(spacing) | |
if constant == 3: | |
return cross | |
elif constant == 4: | |
return normalize_img(parabolic * cross) | |
elif constant == 5: | |
return normalize_img(cross * parabolic * parabolic.T) | |
# Returning those creases which are based on parabolic and linear | |
linear = cross_crease(spacing, 0) | |
if constant == 6: | |
return linear | |
elif constant == 7: | |
return linear.T | |
else: | |
return normalize_img(linear * parabolic) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment