Algorithms for image processing