Color To Grayscale Image Conversion Based On Singular Value Decomposition
Color To Grayscale Image Conversion Based On Singular Value Decomposition
Saudi Arabia
6 Department of Mathematical Sciences, College of Science, Princess Nourah bint Abdulrahman University, Riyadh 11671, Saudi Arabia
ABSTRACT Color information is useless for distinguishing significant edges and features in numerous
applications. In image processing, a gray image discards much-unrequired data in a color image. The
primary drawback of colour-to-grey conversion is eliminating the visually significant image pixels. A current
proposal is a novel approach for transforming an RGB image into a grayscale image based on singular value
decomposition (SVD). A specific factor magnifies one of the color channels (Red, Green, and Blue). A vector
of three values (Red, Green, Blue) of each pixel in an image is decomposed using SVD into three matrices.
The norm of the diagonal matrix was determined and then divided by a specific factor to obtain the grey
value of the corresponding pixel. The contribution of the proposed method gives the user high flexibility to
produce many versions of gray images with varying contrasts, which is very helpful in many applications.
Furthermore, SVD allows for image reconstruction by combining the weighting of each channel with the
singular value matrix. This results in a grayscale image that more accurately captures the actual intensity
values of the image and preserves more color information than traditional grayscale conversion methods,
resulting in loss of color information. The proposed method was compared with a similar method (converting
the color image into grayscale) and was found to be the most efficient.
INDEX TERMS Decolorization, grey image, image conversion, SVD, technological development.
The goal of this algorithm is to convert a color image Algorithm 1: Converting Color Image Into a Grayscale Image
into a grayscale image. Grayscale images have only a single Input: color image
channel of information, where each pixel is represented by Output: grayscale image (Gray Image)
a single gray value instead of three-color values (red, green, Step 1: Input color image (X)
and blue), as in a color image. Step 2: Determine image size (number of rows (NR), number
The algorithm takes a color image (X) as input and sepa- of columns (NC)).
rates it into three color channels (red, green, and blue) using Step 3: Input parameter (k)
the RGB color model. The image size (the number of rows Step 4: Loop i = 1: NR
and columns) was determined. Step 5: Loop j = 1: NC
A loop is then used to iterate through each pixel in the Step 6: Read pixel (X (i, j))
image, starting at the top-left corner (i = 1, j = 1) and Step 7: Separate (X(i, j)) into three channels (Red (xr), Green
progressing row-by-row. (xg), and Blue (xb))
For each pixel, the algorithm creates a vector (C) by read- Step 8: Create a vector for each pixel
ing one byte from each of the three color channels (red, green, C (i, j) = [xr (i, j), xg (i, j), xb (i, j)]
and blue) at the current pixel location (i, j). Optionally, the Step 9: Add weight to one of the three parameters in the
algorithm can apply weight to one of the color channels to vector
create three different vectors (C1, C2, and C3) that can be C (i, j) = [3 × xr (i, j), xg (i, j), xb (i, j)]
used to create three different grayscale images. // Optional: you can create three vectors with different loca-
Singular Value Decomposition (SVD) was then applied tions of weight to get three different gray images
to each vector (C, C1, C2, and C3) separately. SVD is a C1 (i, j) = [3 × xr (i, j), xg (i, j), xb (i, j)]
mathematical process that can decompose a matrix into three C2 (i, j) = [xr (i, j), 3 × xg (i, j), xb (i, j)]
matrices (U, S, and V). These matrices represent the orig- C3 (i, j) = [xr (i, j), xg (i, j), 3 × xb (i, j)]
inal matrix’s rotation, scaling, and reflection. In this step, Step 10: Find the SVD
we focused on the diagonal matrix (S) and neglected the [U S V] = SVD (C (i, j))
other two matrices. The norm value of the diagonal matrix Step 11: Find the gray value
is determined using ‘‘equation (5).’’ G = norm (S) / k
Step 12: Save the result in the gray image
q
S⃗ = s12 +s22 + · · · + sn2 (5)
Gray Image (i, j) = G
where (s) is the value of elements in the diagonal of the Step 13: End loop // (step 5)
(S) matrix and (n) is the number of elements in a diagonal Step 14: End loop // (step 4)
matrix (rank). Step 15: Display the image.
The norm value (which may be larger than the image range
values (255)) is normalized by dividing it by a specific value
(k) to obtain the gray value corresponding to the color pixel.
Parameter (k) controls the degree of contrast in the resulting
grayscale image in addition to normalization.
The algorithm then calculates the gray value (G) for each
pixel using the formula
G = S⃗ /k k = 2, 3 . . . .N (6)
FIGURE 5. The difference between images when adding weight for each
channel (multiply by three), and simple images (dividing parameter equal
two).
FIGURE 8. Comparing the proposed method with other methods. 1. Color image. 2. Matlab. 3. Reference [26]. 4. Reference [27]. 5. Reference [28]. 6.
Reference [29]. 7. Reference [30]. 8. Reference [6]. 9. Proposed method.
Finally, the quality of the converted images for the dif- IX. CONCLUSION
ferent methods was compared and is listed in Table 1. This paper presents a novel and innovative framework for
It is clear from Table 1 that the proposed method pro- grayscale image conversion from color images. It is a mean-
vides a better image quality than the other methods. The ingful conversion that enhances the usual workflow for ana-
SVD method produces grayscale images with a higher visual lyzing images that work on grayscale images. SVD is the
quality than traditional grayscale conversion methods. This best way to convert a vector into other vectors based on
is because SVD considers the relative importance of each the relation between the input vector values. Furthermore,
channel in an image, resulting in a more accurate grayscale SVD can preserve more color information in an image than
image. other gray-scale conversion methods. This is because SVD
considers the relative importance of each channel in the image [16] S. Liu and X. Zhang, ‘‘Image decolorization combining local fea-
and produces a grayscale image that more accurately captures tures and exposure features,’’ IEEE Trans. Multimedia, vol. 21, no. 10,
pp. 2461–2472, Oct. 2019.
the true intensity values of the image. [17] C. Ancuti, C. O. Ancuti, M. Feixas, and M. Sbert, ‘‘Image decolorization
Unlike traditional methods, the proposed method has high based on information theory,’’ in Proc. IEEE Int. Conf. Image Process.
flexibility for producing more than one version of a grayscale (ICIP), Sep. 2019, pp. 3242–3246.
[18] D. C. Lay, R. L. Steven, and J. McDonald, Linear Algebra and Its Appli-
image. The parameters used in this method can help users cations, 5th ed. Boston, MA, USA: Pearson Education Press, 2016.
produce appropriate images for processing and application. [19] H. Zhang, C. Wang, and X. Zhou, ‘‘A robust image watermarking scheme
based on SVD in the spatial domain,’’ Future Internet, vol. 9, no. 3, p. 45,
In addition, we resolved the problem of producing the same Aug. 2017.
value for vectors of the same magnitude using the weight, [20] K. Santosh and B. Gawali, ‘‘Recent trends in image processing and pat-
which yields different values and grayscale images. This tern recognition,’’ in Proc. 3rd Int. Conf. (RTIPR), Aurangabad, India,
vol. 1380, 2020, pp. 1–213.
method’s grayscale image result is highly promising and has [21] B. Barnes, I. Adjei, C. Sebil, and E. Harris, ‘‘Product-normed linear space,’’
very good quality. This method is more efficient than the other Eur. J. Pure Appl. Math., vol. 11, pp. 740–750, Jul. 2018.
[22] K. J. Audu, ‘‘Application of singular value decomposition technique for
methods. compressing images,’’ Gadau J. Pure Allied Sci., vol. 1, no. 2, pp. 82–94,
Aug. 2022.
ACKNOWLEDGMENT [23] D. Varga, ‘‘No-reference image quality assessment with convolutional
This research was funded by Princess Nourah bint Abdulrah- neural networks and decision fusion,’’ Appl. Sci., vol. 12, no. 101, pp. 1–17,
man University and Researchers Supporting Project number 2022.
[24] A. Rubel, O. Ieremeiev, V. Lukin, J. Fastowicz, and K. Okarma, ‘‘Com-
(PNURSP2023R346), Princess Nourah bint Abdulrahman bined no-reference image quality metrics for visual quality assessment
University, Riyadh, Saudi Arabia. The authors would also like optimized for remote sensing images,’’ Appl. Sci., vol. 12, no. 4, p. 1986,
to thank Prince Sultan University, Riyadh Saudi Arabia for Feb. 2022.
[25] N. Venkatanath, D. Praneeth, M. Chandrasekhar, S. S. Channappayya, and
their support. S. S. Medasani, ‘‘Blind image quality evaluation using perception based
features,’’ in Proc. 21st Nat. Conf. Commun. (NCC), Feb. 2015, pp. 1–6.
[26] A. A. Gooch, S. C. Olsen, J. Tumblin, and B. Gooch, ‘‘Color2Gray:
REFERENCES Salience-preserving color removal,’’ ACM Trans. Graph., vol. 24, no. 3,
[1] Y. Yang, M. Song, J. Bu, C. Chen, and C. Jin, ‘‘Color to gray: Atten- pp. 634–639, 2005.
tion preservation,’’ in Proc. 4th Pacific-Rim Symp. Image Video Technol., [27] M. Grundland and N. A. Dodgson, ‘‘Decolorize: Fast, contrast enhanc-
Nov. 2010, pp. 337–342. ing, color to grayscale conversion,’’ Pattern Recognit., vol. 40, no. 11,
[2] A. Güneş, H. Kalkan, and E. Durmuş, ‘‘Optimizing the color-to-grayscale pp. 2891–2896, Nov. 2007.
conversion for image classification,’’ Signal, Image Video Process., vol. 10, [28] K. Smith, P.-E. Landes, J. Thollot, and K. Myszkowski, ‘‘Apparent
no. 5, pp. 853–860, Jul. 2016. greyscale: A simple and fast conversion to perceptually accurate images
[3] Y. Wan and Q. Xie, ‘‘A novel framework for optimal RGB to grayscale and video,’’ Comput. Graph. Forum, vol. 27, no. 2, pp. 193–200, Apr. 2008.
image conversion,’’ in Proc. 8th Int. Conf. Intell. Hum.-Mach. Syst. Cybern. [29] Y. Kim, C. Jang, J. Demouth, and S. Lee, ‘‘Robust color-to-gray via
(IHMSC), vol. 2, Aug. 2016, pp. 345–348. nonlinear global mapping,’’ ACM Trans. Graph., vol. 28, no. 5, pp. 1–4,
[4] K. Kumar, R. K. Mishra, and D. Nandan, ‘‘Efficient hardware of RGB Dec. 2009.
to gray conversion realized on FPGA and ASIC,’’ Procedia Comput. Sci., [30] C. Lu, L. Xu, and J. Jia, ‘‘Contrast preserving decolorization with
vol. 171, pp. 2008–2015, Dec. 2020. perception-based quality metrics,’’ Int. J. Comput. Vis., vol. 110, no. 2,
[5] M. S. M. Rahim, A. Norouzi, A. Rehman, and T. Saba, ‘‘3D bones pp. 222–239, Nov. 2014.
segmentation based on CT images visualization,’’ Biomed. Res., vol. 28,
no. 8, pp. 3641–3644, 2017.
[6] C. T. Nguyen and J. P. Havlicek, ‘‘Color to grayscale image conversion
using modulation domain quadratic programming,’’ in Proc. IEEE Int.
Conf. Image Process. (ICIP), Sep. 2015, pp. 4580–4584. ZAID NIDHAL KHUDHAIR received the B.Sc.
[7] X. Zhang and S. Liu, ‘‘Contrast preserving image decolorization combin- degree in computer science from the University of
ing global features and local semantic features,’’ Vis. Comput., vol. 34, Kufa, Iraq, in 2010, and the M.Sc. degree from the
nos. 6–8, pp. 1099–1108, Jun. 2018. Faculty of Computing, University of Technology
[8] V. Sowmya, D. Govind, and K. P. Soman, ‘‘Significance of incorporating
Malaysia, in 2013, where he is currently pursuing
chrominance information for effective color-to-grayscale image conver-
sion,’’ Signal, Image Video Process., vol. 11, no. 1, pp. 129–136, Jan. 2017.
the Ph.D. degree. He is an Assistant Lecturer with
[9] T. Saba, S. U. Khan, N. Islam, N. Abbas, A. Rehman, N. Javaid, and the Department of Computer Engineering, Imam
A. Anjum, ‘‘Cloud-based decision support system for the detection and Ja’afar Al-Sadiq University. His research interests
classification of malignant cells in breast cancer using breast cytology include computer vision, digital image processing,
images,’’ Microsc. Res. Technique, vol. 82, no. 6, pp. 775–785, Jun. 2019. medical image processing, data and image secu-
[10] S. Liu, ‘‘Two decades of colorization and decolorization for images and rity, computer networking, and real-time applications.
videos,’’ 2022, arXiv:2204.13322.
[11] C. Kanan and G. W. Cottrell, ‘‘Color-to-grayscale: Does the method
matter in image recognition?’’ PLoS ONE, vol. 7, no. 1, Jan. 2012,
Art. no. e29740.
[12] W. H. Lim and N. A. M. Isa, ‘‘Color to grayscale conversion based on AHMED NIDHAL KHDIAR received the B.Sc.
neighborhood pixels effect approach for digital image,’’ in Proc. of 7th Int. and M.Sc. degrees in electronic and communi-
Conf. Elect. Electron. Eng., Bursa, Turkey, 2011, pp. 1–4. cation engineering from Al-Nahrain University,
[13] K. Padmavathi and K. Thangadurai, ‘‘Implementation of RGB and Iraq, and the Ph.D. degree in electronic engi-
grayscale images in plant leaves disease detection–comparative study,’’
neering/signal processing from USM University.
Indian J. Sci. Technol., vol. 9, no. 6, pp. 1–6, Feb. 2016.
[14] H. Z. Nafchi, A. Shahkolaei, R. Hedjam, and M. Cheriet, ‘‘CorrC2G: Color He was an Academic Staff with Al-Sadiq Uni-
to gray conversion by correlation,’’ IEEE Signal Process. Lett., vol. 24, versity, Islamic University, Al-Nahrain University,
no. 11, pp. 1651–1655, Nov. 2017. and Kufa University, for more than 15 years. He is
[15] N. Damodaran, V. Sowmya, D. Govind, and K. P. Soman, ‘‘Effect of decol- currently an Academic Lecturer and a Researcher.
orized images in scene classification using deep convolution features,’’ He published several articles in scientific journals
Procedia Comput. Sci., vol. 143, pp. 954–961, 2018. and IEEE conferences.
NIDHAL K. EL ABBADI received the B.Sc. TANZILA SABA received the Ph.D. degree in document information secu-
degree in chemical engineering from the Univer- rity and management from the Faculty of Computing, Universiti Teknologi
sity of Baghdad, in 1976, the B.Sc. degree (Hons.) Malaysia (UTM), Malaysia, in 2012. She is currently the Associate Chair
in computer science from Al-Mustansiriya Uni- with the Artificial Intelligence and Data Analytics Laboratory (AIDA),
versity, in 2000, and the M.Sc. and Ph.D. degrees Information Systems Department, College of Computer and Information Sci-
in computer science from the Informatics Institute ence, Prince Sultan University, Riyadh, Saudi Arabia. Her research interests
for Postgraduate Studies (IIPS), Iraq Commission include medical imaging, pattern recognition, data mining, MRI analysis,
for Computer and Informatics, in 2001 and 2006, and soft computing.
respectively. He was an Engineer in many indus-
trial plants. In 2006, he joined Al-Mustansiriya
University, Iraq, as an Academic Staff. He is currently a Professor of
computer techniques engineering with the Al-Mustaqbal University. He has
successfully supervised many master’s and Ph.D. students. He published FATEN S. ALAMRI received the Ph.D. degree in system modeling and
more than 300 articles in various international journals and conference analysis in statistics from Virginia Commonwealth University, USA, in 2020.
proceedings and eight books related to computer science. His research Her Ph.D. research was in Bayesian dose response modeling, experimental
interests include image processing, computer vision, steganography, and the design, and nonparametric modeling. She is currently an Assistant Professor
IoT [ACM Classification Codes (I3, I4, I5)]. He acts as a reviewer for various with the Department of Mathematical Sciences, College of Science, Princess
journals and conferences. He served as the conference chair and a technical Nourah bint Abdulrahman University. Her research interests include spatial
committee member for numerous international conferences. areas, environmental statistics, and brain imaging.