select maximum N images for training