  Automatic colorization of gray images with objects of different colors and
sizes is challenging due to inter- and intra-object color variation and the
small area of the main objects due to extensive backgrounds. The learning
process often favors dominant features, resulting in a biased model. In this
paper, we formulate the colorization problem into a multinomial classification
problem and then apply a weighted function to classes. We propose a set of
formulas to transform color values into color classes and vice versa. Class
optimization and balancing feature distribution are the keys for good
performance. Observing class appearance on various extremely large-scale
real-time images in practice, we propose 215 color classes for our colorization
task. During training, we propose a class-weighted function based on true class
appearance in each batch to ensure proper color saturation of individual
objects. We establish a trade-off between major and minor classes to provide
orthodox class prediction by eliminating major classes' dominance over minor
classes. As we apply regularization to enhance the stability of the minor
class, occasional minor noise may appear at the object's edges. We propose a
novel object-selective color harmonization method empowered by the SAM to
refine and enhance these edges. We propose a new color image evaluation metric,
the Chromatic Number Ratio (CNR), to quantify the richness of color components.
We compare our proposed model with state-of-the-art models using five different
datasets: ADE, Celeba, COCO, Oxford 102 Flower, and ImageNet, in both
qualitative and quantitative approaches. The experimental results show that our
proposed model outstrips other models in visualization and CNR measurement
criteria while maintaining satisfactory performance in regression (MSE, PSNR),
similarity (SSIM, LPIPS, UIQI), and generative criteria (FID).
