Skip to content

Instantly share code, notes, and snippets.

@aialenti
Created February 14, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aialenti/67d494f7cd6bb62992738a96839f1de6 to your computer and use it in GitHub Desktop.
Save aialenti/67d494f7cd6bb62992738a96839f1de6 to your computer and use it in GitHub Desktop.
#import numpy as np
#import pandas as pd
#from tqdm import tqdm
#import cv2
#from src.commons import utils
#from constants import
def resize_images(data, size=None):
'''
Resize the images
:param data: The dataframe with all the information
:param size: None or a tuple with width and height of the output images
:return:
'''
if size is not None:
data['width_cm'] = size[0]
data['height_cm'] = size[1]
for ix, row in tqdm(data.iterrows()):
image = utils.load_image('{}/{}.jpg'.format(IMAGE_FOLDER, row.title))
# Reshape image according to what's in the data
image_width = row['width_cm'] SCALE_FACTOR
image_height = row['height_cm'] SCALE_FACTOR
res = cv2.resize(image, dsize=(int(image_width), int(image_height)), interpolation=cv2.INTER_CUBIC)
cv2.imwrite('{}/{}.jpg'.format(IMAGE_RESHAPED_FOLDER, row.title), res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment