Functions for image processing.