MECOMARE, x (x) (20xx) pp.
xx-xx
Published by: TRIGIN Publisher
International Journal of Mechanical Computational and Manufacturing Research
Journal homepage: www.trigin.pelnus.ac.id
Pap Smear digital image management using grayscale
transform and histogram equalization method
Kusnadi1*
1,
Engineering Informatics, Nahdlatul Ulama Univessity East Kalimantan, Samarinda, Indonesia
ARTICLE INFO ABSTRACT
Article history: This experiment aims to process digital images by performing the
following steps: first, converting the original color image into an RGB
Received filled by editors format and providing histograms of all color pixels and histograms for
Revised filled by editors each RGB channel. Next, the RGB image is transformed into a
Accepted filled by editors grayscale image, accompanied by histograms and contours of the
grayscale image. This process includes grayscale transformation and
Keywords: histogram equalization, with results compared to images from reverse
operations. Additionally, the experiment compares images before and
Digital image; after histogram equalization, including their respective histograms.
Grayscale image; This paper proposes improved methods for grayscale transformation
Grayscale transformation; and histogram equalization to better explain the characteristics of the
Histogram equalization; algorithm. The final results of digital image processing using these
methods can assist those who struggle with color differentiation
through grayscale changes. The algorithm effectively processes dark
and low-contrast images, enhancing image quality by improving
average brightness, natural color, and detail, thus providing significant
application value.
This is an open access article under the CC BY-NC license.
Corresponding Author:
Kusnadi,
Engineering Informatics,
Nahdlatul Ulama Univessity East Kalimantan,
Jl. KH. Harun Nafsi Gang Dharma, Rapak Dalam, Kota Samarinda, Indonesia.
Email: [email protected]
1. INTRODUCTION
The rapid advancement of digital imaging technology has led to a growing need for effective image
processing techniques (Archana & Jeevaraj, 2024). As digital cameras, smartphones, and other
imaging devices become ubiquitous, the ability to manipulate and enhance digital images has
become increasingly important across many fields. This paper focuses on two fundamental image
processing methods: grayscale transformation and histogram equalization.
Grayscale transformation is a crucial technique for simplifying color images while retaining
essential structural information. By converting RGB color images to grayscale, we can reduce
computational complexity and highlight important features for further analysis (Gonzalez, 2008).
This process involves carefully mapping color intensities to grayscale values to preserve image
contrast and detail. The advantages of using grayscale images include reduced storage
requirements, faster processing times, and simplified analysis for certain applications such as edge
detection and pattern recognition (Sonka et al., 2015).
Histogram equalization, on the other hand, is a powerful method for enhancing image
contrast. By redistributing pixel intensities across the available range, histogram equalization can
dramatically improve the visibility of details in both underexposed and overexposed images (Kim,
1997). This technique is particularly valuable in fields like medical imaging, where subtle variations
Journal homepage: www.trigin.pelnus.ac.id
2 ISSN 2301-4148 (Print) | 2962-3391 (Online)
in tissue density can be critical for diagnosis (Reza, 2004). The benefits of histogram equalization
include improved contrast, enhanced visibility of image details, and the ability to normalize images
for consistent analysis across different lighting conditions (Pizer et al., 1987).
These techniques offer several key advantages in image processing, including; firstly
improved image quality: Both methods can enhance the visual appearance of images, making
details more apparent and easier to interpret (Chang et al., 2018). Second, enhanced feature
extraction: Grayscale transformation and histogram equalization can highlight important image
features, facilitating more accurate analysis in computer vision applications (Caron & Markusen,
2016). Third, reduced computational complexity: Working with grayscale images often reduces
processing time and memory requirements compared to full-color images (Gonzalez, 2008). And
the fourth, normalized image representation: Histogram equalization can help standardize image
brightness and contrast, making it easier to compare images from different sources or lighting
conditions (Yang et al., 2022) and (Moghimi & Mohanna, 2021).
In this paper, we explore these two techniques in depth, examining their mathematical
foundations, implementation methods, and practical applications. We demonstrate how grayscale
transformation and histogram equalization can be applied to enhance image quality and extract
valuable information from digital images. Through a series of experiments and visual examples, we
illustrate the effectiveness of these methods in various scenarios and discuss their strengths and
limitations.
By providing a comprehensive overview of grayscale transformation and histogram
equalization, this work aims to equip readers with a solid understanding of these essential image
processing tools. These techniques serve as building blocks for more advanced image analysis
and computer vision applications, making them invaluable for researchers and practitioners
working with digital imagery.
2. RESEARCH METHOD
2.1. Digital Image
A digital image is a numerical representation of a two-dimensional (2D) image (Gonzalez,
2008). Digital images can be classified into vector or bitmap types, depending on whether the
resolution is fixed or changeable (Hähnlein et al., 2019). Bitmap images consist of a finite number
of pixels, with the number of pixels in rows and columns being fixed. A pixel, the smallest individual
element in an image, stores the color description value at that point (Tyagi, 2018).
When a bitmap image is enlarged, it may appear pixelated or "broken" (Suresh et al., 2013)
and (Lee & Park, 2017). Typically, pixels are stored on computers as bitmap or raster map images
in the form of a 2D array of small integers and are often transmitted or stored in compressed form
(Jamil et al., 2023) and (Chen, 2021).Vector imagery, on the other hand, originates from geometry.
A vector consists of points that have both direction and length (Hou et al., 2020) and (Brown,
2016). Many images incorporate both bitmap and vector elements, such as a billboard featuring
text (vector) and a photograph (bitmap) (Cal-Gonzalez et al., 2018) and (Wilson, 2018).
Digital imagery can be viewed using various software applications, including "Windows
Photo Viewer". Web browsers are capable of displaying standard image formats like GIF, JPEG,
and PNG (Sitohang & Sindar, 2020). Additionally, web browsers can render SVG (Scalable Vector
Graphics) format. (Sitohang & Sindar, 2020).
2.2. Grayscale Image
A grayscale image is an image that displays only different levels of gray color. A 'grayscale'
color consists of red, green, and blue colors of equal intensity in RGB space, so each pixel requires
only one intensity value. This is in contrast to color images which require three intensity values for
each pixel (Gonzalez, 2008).
Grayscale images consist of varying degrees of darkness from deep black to bright white.
In simple terms, these images consist of black, white, and various shades of gray, with varying
degrees of gray brightness. In grayscale images, the value of each pixel depends on the number of
data bits used to represent it. Typically, grayscale values are represented by 8 bits, which is a
combination of eight binary numbers that determine the value of that pixel. Therefore, the range of
Int. J. MECOMARE, Vol.xx, No. xx, (Mount) 20xx: pp xx-xx
3Int. J. MECOMARE ISSN 2301-4148 (Print) | 2962-3391 (Online)
pixel values is from 0 to 255 (0b00000000 to 0b11111111, where “0b” indicates the number in
binary format), for a total of 256 grayscale levels. If a 16-bit number is used for pixel value
representation, then the value range becomes 0 to 65,535, with a total of 65,536 grayscale levels
(Varoslavskiy, 1977).
In digital image processing, various procedures are applied to manipulate and analyze
visual data. One common technique involves converting a color image into a grayscale
representation. This process is typically performed on images using the RGB color model, which
comprises three distinct matrix layers: the R (red), G (green), and B (blue) layers (Savakar G.
Dayanand & Pujar, 2018). When calculations are executed on a color image, they must be carried
out separately on each of these three layers. To obtain a grayscale image from a color original, a
specific formula is employed that combines information from all three color channels. This
conversion simplifies the image data while preserving important structural and intensity information,
making subsequent processing steps more efficient and less computationally intensive (Riana et
al., 2022)
To convert a color image into a grayscale image, each pixel in the color image is
transformed into a single grayscale value. This grayscale value is typically calculated using a
weighted average formula based on the intensity values of the RGB components. A commonly
used formula is:
Grayscale = 0.3 RED + 0.59GREEN + 0.11 BLUE …………………………………………. (1)
A grayscale image is an image that contains shades of gray (Nabusa, 2019). [19] The use
of grayscale images is preferred because they require less information compared to colored
images, as each pixel doesn't need three intensity values like in colored images. In a grayscale
image, the gray color consists of a single intensity value of red (R), green (G), and blue (B) (Riana
et al., 2022) and (Yulina, 2021).
The intensity in a grayscale image is stored as an 8-bit integer, providing 256 possible
values ranging from 0 to 255 (0 for black, 255 for white, and the values in between represent
different shades of gray) (Yulina, 2021).
2.3. Grayscale Transformation
Gray Scale Transformation is a technique in digital image processing used to modify the
intensity values of pixels in a grayscale image. A grayscale image is one in which each pixel
represents the intensity of light from black to white, without any color. This intensity is typically
represented as a value between 0 (black) and 255 (white) in an 8-bit format (Jamil et al., 2023) and
(Kaur & Kaur, 2018).
The transformation process involves iterating through each pixel in the color image and
applying the above formula to calculate the grayscale value (Sonka et al., 2015) and (Tyagi, 2018).
This grayscale value is then used to replace the original RGB values of the pixel. The result of this
transformation is a new image in which each pixel has a single grayscale intensity value. This
image has only one channel (grayscale) compared to the three channels (RGB) in the color image.
The transformation you mentioned is an example of linear contrast stretching, a technique
commonly used in image processing to enhance image contrast. The linear function used in this
transformation is given by:
g(x) = a . f (x) + b …………………………………………………… (2)
where f(x) is the initial pixel intensity value, a is the scale (gain), and b is the offset (Gonzalez,
2008).
In grayscale transformation, there is also a process of contrast adjustment, allowing us to
enhance or reduce the contrast of an image. For example, by altering the range of intensity values,
we can make the difference between dark and light areas more pronounced or more subtle. This
transformation also enables the adjustment of the image's brightness by adding a constant value to
all pixels, making the image appear brighter or darker (Roy et al., 2024).
2.4. Histogram Equalization
Kusnadi, Pap Smear digital image management using grayscale transform and histogram equalization
method
4 ISSN 2301-4148 (Print) | 2962-3391 (Online)
Another technique commonly used in grayscale image transformation is histogram
equalization. This method enhances image contrast by spreading the pixel intensity values evenly
across the available range (Roy et al., 2024) and (Ibrahim et al., 2024).
Histogram Equalization is an image processing technique used to enhance the contrast of an
image by equalizing the distribution of pixel intensities (Baidoo, 2018). The goal of this technique is
to transform the intensity histogram of the input image so that the resulting histogram has a more
uniform distribution. In other words, it makes dark areas lighter and light areas darker, thereby
making previously less visible details in the image more prominent. This method helps in improving
the overall visibility and clarity of the image (Gonzalez, 2008) and (Baidoo, 2018).
3. RESULTS AND DISCUSSIONS
3.1. Result
The Pap smear images used in this study were obtained from the RepoMed database of
Nusa Mandiri University, Jakarta. In this experiment, we utilized the openCV model with the
proposed methods of grayscale transformation and histogram equalization, using the Google Colab
application. The stages in this experiment are as follows:
First, load several libraries that will be used, including numpy, pandas, cv2, skimage, PIL, and
matplotlib.
Step Two: Inputting the Original Image and Reading the Output Image. The process involves
inputting the original image and converting it into RGB format. The result of this conversion can be
seen in Figure 1.
.
(1a) (1b)
Figure 1a. Original Image and Figur 1b. RBG Image
Step three, involves image contour processing and image histogram. At the beginning of the
process, the matrix data type of the image is checked to determine the bit depth of the image. The
image data obtained includes height = 2448, width = 3264, and the number of image channels = 3.
Next, the processing involves manipulating the image to generate histograms from all the color
image pixels, which can be seen in Figure 2a, and the histogram of the RGB image channels as
shown in Figure 2b.
(2a) (2b)
Figure 2a. Histogram of all pixels in the color image and Figure 2b. Histogram of RGB channels
Int. J. MECOMARE, Vol.xx, No. xx, (Mount) 20xx: pp xx-xx
5Int. J. MECOMARE ISSN 2301-4148 (Print) | 2962-3391 (Online)
The fourth step is the processing of color images from the RGB channels into grayscale images,
resulting in histograms in the grayscale. The results are as shown in Figures 4 and Figure 5.
Figure 4. Grayscale images Figure 5. Histogram of a grayscale image
Step five is to perform image contour processing, using the grayscale image shown in the
following Figure 6.
Figure 6. Contour of grayscale image
Step six, mathematical transformation of the grayscale image, performs the reverse operation of
the grayscale image, converting dark colors to light and light colors to dark. The result of this
processing can be seen in Figure 7.
Kusnadi, Pap Smear digital image management using grayscale transform and histogram equalization
method
6 ISSN 2301-4148 (Print) | 2962-3391 (Online)
Figure 7. Image of color change from dark to light and from light to dark
Next, the transformation of the grayscale image involves adding a constant that makes all the
pixels brighter, resulting in an effect where the brightness level of the grayscale image decreases.
This can be seen in Figure 8.
Figure 8. Grayscale image after the addition of a constant
The seventh step is histogram equalization. This processing has produced an output of grayscale
images and histograms that differ from the grayscale image and histogram before and after
histogram equalization. The result shows a noticeable difference between Figure 8a and 8b.
Int. J. MECOMARE, Vol.xx, No. xx, (Mount) 20xx: pp xx-xx
7Int. J. MECOMARE ISSN 2301-4148 (Print) | 2962-3391 (Online)
Figure 8a. Before histogram equalization
Figure 8b. After histogram equalization
3.2. Discussion
In the image processing process, the histogram of all pixels in the color image 4 does not yet
allow for a detailed analysis of pixels per RGB channel. After color separation is performed,
histograms for each RGB channel can be analyzed, as shown in Figure 3. From Figure 3, it is
observed that the green channel has pixels at value 255, indicating white areas in the image (Roy
et al., 2024). The color image processing of the RGB channels results in 12 grayscale images, as
shown in Figure 7, along with the grayscale histograms displayed in Figure 8. The observed
changes indicate that the frequency in the image histogram has decreased to one-third of the
histogram of the color image with bins= 256 and range = 0 – 256.
Generally, researchers suggest that histogram equalization is a method for automating
procedures, which is an intriguing mathematical technique as it maximizes image entropy, a
measure of how much information is conveyed by a fixed number of bits (Trongtirakul & Agaian,
2021). This section demonstrates the histogram of a dark image. This transformation equalizes the
grayscale histogram, making the intensity uniform across the image (Gonzalez, 2008). The image
transformation function involves the cumulative distribution function (cdf) of pixel values in the
image or is normalized to map the pixel value range to the desired range. Grayscale scaling
transformations can significantly improve image visibility but often require many trials and errors
(Caron & Markusen, 2016).
The histogram equalization function aims to standardize the intensity distribution in
grayscale images and obtain a more uniform histogram. This function also plays a role in
Kusnadi, Pap Smear digital image management using grayscale transform and histogram equalization
method
8 ISSN 2301-4148 (Print) | 2962-3391 (Online)
cumulative distribution, enhancing image contrast, and improving the contrast of the black
background. (Caron & Markusen, 2016). Histogram equalization is performed automatically using
the histogram as a contrast weighting curve, reducing the need for human evaluation. In other
words, the output transformation is achieved through histogram integration and normalization,
without requiring manually created curves. (Moghimi & Mohanna, 2021).
4. CONCLUSION
Advancements in image processing technology have played a crucial role in enhancing image
quality by selectively conveying certain information and visual effects. Pseudo-color enhancement
refers to the technology that converts grayscale images into color images through linear or
nonlinear mapping functions. This paper proposes a method for grayscale transformation and
histogram equalization aimed at addressing defects in image enhancement. During color image
enhancement, this method processes images in the RGB space to improve existing or missing
colors. Through experimentation and analysis, it has been found that the improved algorithm can
achieve better image enhancement for most dark images. The grayscale transformation and
histogram equalization methods can be applied in future research with biomedical, biometric, and
other image datasets to clarify the images intended for analysis.
REFERENCES
Archana, R., & Jeevaraj, P. S. E. (2024). Deep learning models for digital image processing: a
review. In Artificial Intelligence Review (Vol. 57, Issue 1). Springer Netherlands.
https://doi.org/10.1007/s10462-023-10631-z
Baidoo, E. (2018). Implementation of Gray Level Image Transformation Techniques. International
Journal of Modern Education and Computer Science, 10(5), 44–53.
https://doi.org/10.5815/ijmecs.2018.05.06
Cal-Gonzalez, J., Rausch, I., Sundar, L. K. S., Lassen, M. L., Muzik, O., Moser, E., Papp, L., &
Beyer, T. (2018). Hybrid imaging: Instrumentation and data processing. Frontiers in Physics,
6(MAY). https://doi.org/10.3389/fphy.2018.00047
Caron, J., & Markusen, J. R. (2016). The Image Processing Handbook. CRC Press Taylor &
Francis Group. https://doi.org/10.1201/b18983
Chang, Y., Jung, C., Ke, P., Song, H., & Hwang, J. (2018). Automatic Contrast-Limited Adaptive
Histogram Equalization with Dual Gamma Correction. IEEE Access, 6, 11782–11792.
https://doi.org/10.1109/ACCESS.2018.2797872
Gonzalez, R. C. (2008). Digital Image Processing. Library of Congress Cataloging in Publication
data on File. www.EBooksWorld.ir
Hähnlein, F., Gryaditskaya, Y., & Bousseau, A. (2019). Bitmap or Vector? A study on sketch
representations for deep stroke segmentation. Journées Francaises d’ ….
https://hal.inria.fr/hal-02922043/
Hou, F., Sun, Q., Fang, Z., Liu, Y. J., Hu, S. M., Qin, H., Hao, A., & He, Y. (2020). Poisson Vector
Graphics (PVG). IEEE Transactions on Visualization and Computer Graphics, 26(2), 1361–
1371. https://doi.org/10.1109/TVCG.2018.2867478
Int. J. MECOMARE, Vol.xx, No. xx, (Mount) 20xx: pp xx-xx
9Int. J. MECOMARE ISSN 2301-4148 (Print) | 2962-3391 (Online)
Ibrahim, H., Abd, A. E. N., Ammar, R., El-Hag, N. A., Abou-Elazm, A., Abd El-Samie, F. E., El-
Shafai, W., & Elsafrawey, A. (2024). Efficient color image enhancement using piecewise
linear transformation and gamma correction. Journal of Optics (India), 53(3), 2027–2037.
https://doi.org/10.1007/s12596-023-01171-4
Jamil, S., Piran, M. J., Rahman, M. U., & Kwon, O. J. (2023). Learning-driven lossy image
compression: A comprehensive survey. Engineering Applications of Artificial Intelligence, 123,
1–14. https://doi.org/10.1016/j.engappai.2023.106361
Kaur, A., & Kaur, G. (2018). A review on image enhancement with deep learning approach.
ACCENTS Transactions on Image Processing and Computer Vision, 4(11), 16–20.
https://doi.org/10.19101/tipcv.2018.411002
Kim, Y. T. (1997). Contrast enhancement using brightness preserving bi-histogram equalization.
IEEE Transactions on Consumer Electronics, 43(1), 1–8. https://doi.org/10.1109/30.580378
Moghimi, M. K., & Mohanna, F. (2021). Real-time underwater image enhancement: a systematic
review. Journal of Real-Time Image Processing, 18(5), 1509–1525.
https://doi.org/10.1007/s11554-020-01052-0
Nabusa, Y. N. (2019). Pengolahan Citra Digital Perbandingan Metode Histogram Equalization Dan
Spesification Pada Citra Abu-Abu. J-Icon, 7(1), 87–95.
Pizer, S. M., Amburn, E. P., Austin, J. D., Cromatie, R., Geselowitz, A., Greer, T., Romeny, B. T.
H., Zimmerman, J. B., & Zuiderveid, K. (1987). Adaptive histogram equalization and its
variations. In Computer Vision, Graphics, and Image Processing (Vol. 38, Issue 1, p. 99).
https://doi.org/10.1016/s0734-189x(87)80156-1
Reza, A. M. (2004). Realization of the contrast limited adaptive histogram equalization (CLAHE) for
real-time image enhancement. Journal of VLSI Signal Processing Systems for Signal, Image,
and Video Technology, 38(1), 35–44. https://doi.org/10.1023/B:VLSI.0000028532.53893.82
Riana, D., Kusnadi, & Syahrani, M. (2022). Pengelolaan Citra Digital Dengan Menggunakan
Metode Transformasi Gryascale dan Pemerataan Histogram. Jurnal Teknik Informatika
Kaputama (JTIK), 6(1), 108–119. https://jurnal.kaputama.ac.id/index.php/JTIK/article/view/724
Roy, S., Bhalla, K., & Patel, R. (2024). Mathematical analysis of histogram equalization techniques
for medical image enhancement: a tutorial from the perspective of data loss. Multimedia
Tools and Applications, 83(5), 14363–14392. https://doi.org/10.1007/s11042-023-15799-8
Savakar G. Dayanand, & Pujar, S. (2018). Digital Image Watermarking Using DWT and FWHT.
International Journal of Image, Graphics and Signal Processing, 10(6), 50–67.
https://doi.org/10.5815/ijigsp.2018.06.06
Sitohang, B., & Sindar, A. (2020). Analisis Dan Perbandingan Metode Sobel Edge Detection Dan
Prewit Pada Deteksi Tepi Citra Daun Srilangka. Jurnal Nasional Komputasi Dan Teknologi
Informasi (JNKTI), 3(3), 314–322. https://doi.org/10.32672/jnkti.v3i3.2511
Sonka, M., Hiavac, V., & Boyle, R. (2015). Image processing, Analysis, and Machine Vision. Global
Engineering. www.cengage.com/highered
Suresh, C., Singh, S., Saini, R., & Saini, A. K. (2013). A Comparative Analysis of Image Scaling
Algorithms. International Journal of Image, Graphics and Signal Processing, 5(5), 55–62.
https://doi.org/10.5815/ijigsp.2013.05.07
Kusnadi, Pap Smear digital image management using grayscale transform and histogram equalization
method
10 ISSN 2301-4148 (Print) | 2962-3391 (Online)
Trongtirakul, T., & Agaian, S. S. (2021). Weighted Histogram Equalization Using Entropy of
Probability Density Function. 1, 461–464.
Tyagi, V. (2018). Understanding Digital Image Processing. Understanding Digital Image
Processing, November. https://doi.org/10.1201/9781315123905
Varoslavskiy, L. P. (1977). Digital Image Processing. In Telecommunications and Radio
Engineering (English translation of Elektrosvyaz and Radiotekhnika) (Vols. 31–32, Issue 11).
Yang, C., Jin, M., Xu, Y., Zhang, R., Chen, Y., & Liu, H. (2022). SepLUT: Separable Image-
Adaptive Lookup Tables for Real-Time Image Enhancement. Lecture Notes in Computer
Science (Including Subseries Lecture Notes in Artificial Intelligence and Lecture Notes in
Bioinformatics), 13678 LNCS, 201–217. https://doi.org/10.1007/978-3-031-19797-0_12
Yulina, S. (2021). Penerapan Haar Cascade Classifier dalam Mendeteksi Wajah dan Transformasi
Citra Grayscale Menggunakan OpenCV. Jurnal Komputer Terapan, 7(1), 100–109.
https://jurnal.pcr.ac.id/index.php/jkt/
Int. J. MECOMARE, Vol.xx, No. xx, (Mount) 20xx: pp xx-xx