# -*- coding: utf-8 -*-
"""
Created on Fri Apr 16 21:47:31 2021

@author: xhrton02
"""

# example of extracting and resizing faces into a new dataset
from os import listdir  
from numpy import asarray
from numpy import load
from numpy import savez_compressed
from matplotlib import pyplot
from keras.preprocessing.image import img_to_array
from keras.preprocessing.image import load_img

# directory that contains all images
directory = "D:/hrtoňová/datasets/melanoma_dataset/train/"

images = list()


list_dir = listdir(directory)

if '.DS_Store' in list_dir:
    list_dir.remove('.DS_Store')
    
# enumerate files  
for filename in list_dir:
		# load the image
	img = load_img(directory + filename, target_size=(256,256))
	img = img_to_array(img)
	images.append(img)

images = asarray(images,dtype='uint8')

# save in compressed format
savez_compressed('melanoma_dataset_256.npz', images)