diff --git a/deep-fry/42.png b/deep-fry/42.png new file mode 100644 index 0000000..1ec0203 Binary files /dev/null and b/deep-fry/42.png differ diff --git a/deep-fry/e0eff0403df8f7245c0f2e3d792390d0.png b/deep-fry/e0eff0403df8f7245c0f2e3d792390d0.png new file mode 100644 index 0000000..0038fc1 Binary files /dev/null and b/deep-fry/e0eff0403df8f7245c0f2e3d792390d0.png differ diff --git a/deep-fry/fry.png b/deep-fry/fry.png new file mode 100644 index 0000000..08302e1 Binary files /dev/null and b/deep-fry/fry.png differ diff --git a/deep-fry/iczero.png b/deep-fry/iczero.png new file mode 100644 index 0000000..5b116e1 Binary files /dev/null and b/deep-fry/iczero.png differ diff --git a/deep-fry/image0.jpg b/deep-fry/image0.jpg new file mode 100644 index 0000000..323e92f Binary files /dev/null and b/deep-fry/image0.jpg differ diff --git a/deep-fry/output-temp.png b/deep-fry/output-temp.png new file mode 100644 index 0000000..0678c38 Binary files /dev/null and b/deep-fry/output-temp.png differ diff --git a/deep-fry/test.py b/deep-fry/test.py new file mode 100644 index 0000000..59a9933 --- /dev/null +++ b/deep-fry/test.py @@ -0,0 +1,28 @@ +import sys + +import numpy as np +import cv2 + +# reads in the image +image = cv2.imread(sys.argv[1], flags=cv2.IMREAD_COLOR) + +def fry(image, saturation): + # sets the green channel equal to the + # increase saturation + hsvImg = cv2.cvtColor(image,cv2.COLOR_BGR2HSV) + hsvImg[...,1] = hsvImg[...,1]*saturation + image=cv2.cvtColor(hsvImg,cv2.COLOR_HSV2BGR) + + image[...,0] = image[...,0] * 1.1 # sets the red channel to the green channel + image[...,1] = image[...,0] * 1.1 # sets the red channel to the green channel + return image + +def sharp(image): + # sharpening kernel + kernel = np.array([[0, -1, 0], + [-1, 5,-1], + [0, -1, 0]]) + return cv2.filter2D(src=image, ddepth=-1, kernel=kernel) + +cv2.imwrite("fry.png", fry(image, 1.4)) +cv2.imwrite("output.png", fry(sharp(sharp(image)), 5)) diff --git a/main.py b/main.py index 510e7fa..74ed465 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,9 @@ import os import os.path +import numpy as np +import cv2 + try: TOKEN = os.environ["BONOBOT_TOKEN"] except: @@ -159,6 +162,21 @@ def get_best_random(users, members): currRandom.add(candidate) users[i] = candidate +def fry(image): + # sets the green channel equal to the + # increase saturation + hsvImg = cv2.cvtColor(image,cv2.COLOR_BGR2HSV) + hsvImg[...,1] = hsvImg[...,1]*5 + image=cv2.cvtColor(hsvImg,cv2.COLOR_HSV2BGR) + + return image + +def sharp(image): + # sharpening kernel + kernel = np.array([[0, -1, 0], + [-1, 5,-1], + [0, -1, 0]]) + return cv2.filter2D(src=image, ddepth=-1, kernel=kernel) class BonoboCog(commands.Cog): def __init__(self, bot): @@ -170,8 +188,12 @@ async def get_avatar(self, user: Union[nextcord.User, nextcord.Member]) -> Image avatar_bytes = await user.display_avatar.read() return Image.open(BytesIO(avatar_bytes)) + @commands.command(aliases=["nft"]) + async def deepfry(self, ctx, users:commands.Greedy[DiscordMonke]): + await self.bonobo(ctx,users,True) + @commands.command(aliases=["bonobot"]) - async def bonobo(self, ctx, users: commands.Greedy[DiscordMonke]): + async def bonobo(self, ctx, users: commands.Greedy[DiscordMonke], deepfry=False): if len(users) == 0 and len(ctx.message.clean_content.split()) == 1: users = [LazyRandom()] * random.choice(tuple(self.templates)).faces get_best_random( @@ -200,7 +222,10 @@ async def bonobo(self, ctx, users: commands.Greedy[DiscordMonke]): im = pasteImg( im, top, template.upperleftcord(count), template.lowerrightcord(count) ) - + if deepfry: + opencvImage = cv2.cvtColor(np.array(im), cv2.COLOR_RGB2BGR) + im = Image.fromarray(fry(sharp(sharp(opencvImage)))) + # deepfry buffer = BytesIO() im.save(buffer, "png") buffer.seek(0) diff --git a/requirements.txt b/requirements.txt index 3b7f94a..9eda53e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,9 @@ imageio == 2.9.0 # Bonobot/main.py: 3,4 nextcord == 2.0.0a3 + +# numpy +numpy + +# opencv +opencv-python