def __init__(self,img):
#making two copies of the same image
original_img = np.array(img)
new_img = np.array(img)
#resizing keeping the aspect ratio constant
a_ratio = new_img.shape[0]/new_img.shape[1]
#new_row=int(new_img.shape[0])
new_row = 128
new_colm = int(new_row/a_ratio)
new_img = cv2.resize(new_img, (new_colm,new_row), interpolation = cv2.INTER_AREA)
original_img = cv2.resize(original_img, (new_colm,new_row), interpolation = cv2.INTER_AREA)
#convert new_one to grayscale
new_img = cv2.cvtColor(new_img,cv2.COLOR_BGR2GRAY)
self.original_img = original_img
self.new_img = new_img
评论列表
文章目录