Image processing base function