Improved image comparison algorithm

Added histogram comparison to save time