Automatic colorization of grayscale images using weighted functions for feature balancing and class optimization.