Refactored php code a bit.
Train images by drawing squares on them.