Closed JianxiangWang closed 5 years ago
I had created a script to do the same. I'll add it to the repository soon. Thanks
import matplotlib.pyplot as plt
from glob import glob
filelist = sorted(glob('testing/*.bmp')) # ('images/*.bmp')
for i in range(len(filelist)):
img = cv2.imread(filelist[i])
x = int(np.floor((img.shape[1]-256)/2))
crop_img = img[0:256, x:x+256]
# cv2.imshow("cropped", crop_img)
# cv2.waitKey(1000)
filename = 'testing_cropped_images/' + str(i) + '.bmp'
# filename = 'cropped_images/' + str(i) + '.bmp'
print(filename)
cv2.imwrite(filename, crop_img)
You might have to make some changes to this @JianxiangWang . But this should do the trick, or give you an idea on how to do this.
@karanvivekbhargava do you need to crop images of the head will https://github.com/leblancfg/autocrop work, also I am looking to turn the whole process in google colab
Is this code snippet supposed to crop the mouth region ? If yes, do we tweak it manually to crop the mouth ? Thanks for sharing
import matplotlib.pyplot as plt from glob import glob filelist = sorted(glob('testing/*.bmp')) # ('images/*.bmp') for i in range(len(filelist)): img = cv2.imread(filelist[i]) x = int(np.floor((img.shape[1]-256)/2)) crop_img = img[0:256, x:x+256] # cv2.imshow("cropped", crop_img) # cv2.waitKey(1000) filename = 'testing_cropped_images/' + str(i) + '.bmp' # filename = 'cropped_images/' + str(i) + '.bmp' print(filename) cv2.imwrite(filename, crop_img)
You might have to make some changes to this @JianxiangWang . But this should do the trick, or give you an idea on how to do this.
Also could you please provide the steps (no code just how you went from images to cropped/patched to end result) it seems your readme file is missing some parts
Copy the patched images into folder a and the cropped images to folder b
==> Could you release the code about how to get the cropped images ?Thank you ~