Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PIL import Image
- import os
- img_dir = "./sal1000-2"
- area_left = (250,340,350+16,340+37)
- area_right = (419,340,419+16,340+37)
- left_init = ()
- right_init = ()
- left = ()
- right = ()
- flag = 0
- for file in sorted(os.listdir(img_dir)):
- if file.endswith(".jpg"):
- img = Image.open(img_dir+"/"+file)
- # CROP THE IMAGE
- cropped_left = img.crop(area_left)
- cropped_right = img.crop(area_right)
- # RESIZE THE IMAGES
- resized_left = cropped_left.resize((1,1))
- resized_right = cropped_right.resize((1,1))
- # Keep the initial values from the first image
- if flag == 0 :
- left_init = resized_left.getpixel((0,0))
- right_init = resized_right.getpixel((0,0))
- flag = 1
- else :
- left = resized_left.getpixel((0,0))
- right = resized_right.getpixel((0,0))
- redL = left[0]-left_init[0]
- greenL = left[1]-left_init[1]
- blueL = left[2]-left_init[2]
- redR = right[0]-right_init[0]
- greenR = right[1]-right_init[1]
- blueR = right[2]-right_init[2]
- print("LEFT: t", str(greenL-blueL), "t RIGHT: t", str(greenR-blueR), file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement