This overall process is applied twice, one on the average gray level of the original image and the other on the layer of dominant color of the original image (in RGB). We define a layer as dominant if the sum of its pixel values is bigger than the corresponding sum of the other two layers: