function [images, labels] = get_batch(imdb, batch)
%This function reutrns a batch of training images and their corresponding labels
%from the database structure (imdb) based on the indexes in the 'batch' input. 

%Select the images and labels of the batch
images = imdb.images.data(:,:,:,batch);
labels = imdb.images.labels(1,batch);

%We can apply data augmentation on the batch images: here we use only image
%horizontal filpping with the probability of 0.5
if rand > 0.5
    images=fliplr(images); 
end