Intelligent Image Processing in Prolog