Defined several utility functions for image processing.