Skip to content

Instantly share code, notes, and snippets.

@ayyucedemirbas
Created July 16, 2022 00:13
Show Gist options
  • Save ayyucedemirbas/a7cdedc9404b6d5ff69f447cc621b74d to your computer and use it in GitHub Desktop.
Save ayyucedemirbas/a7cdedc9404b6d5ff69f447cc621b74d to your computer and use it in GitHub Desktop.
from os import listdir
from os.path import isfile, join
from PIL import Image, ImageOps, ImageChops, ImageFilter
import random
import glob
mypath = "dermnetMini/train/Acne/"
imagefiles = glob.glob(mypath + '*.jpg')
cnt=0
for my_image in imagefiles:
img = Image.open(my_image)
mirror_img = ImageOps.mirror(img)
mirror_img.save(mypath+ str(cnt)+"_mirror.jpg")
img_to_shift = Image.open(my_image)
img_shifted =ImageChops.offset(img_to_shift, -800, -400)
img_shifted.save(mypath + str(cnt) +'_shifted.jpg')
with Image.open(my_image) as im:
im.rotate(120).save(mypath+str(cnt) +"_rotated.jpg")
print(my_image)
cnt=cnt+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment