-
-
Save aialenti/67d494f7cd6bb62992738a96839f1de6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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