Automatic Red Eye Remover using OpenCV

HAC
Google Scholar
To share
Primbetov, A. (2024). Automatic Red Eye Remover using OpenCV. Modern Science and Research, 3(1), 1–3. Retrieved from https://inlibrary.uz/index.php/science-research/article/view/28257
Crossref
Сrossref
Scopus
Scopus

Abstract

Red-eye is a common issue in flash photography that occurs when the camera flash reflects off the subject's retina, resulting in a red or orange coloration in the eyes. Manual removal of red-eye can be time-consuming and tedious, especially when dealing with a large number of images. This paper presents an automatic red-eye removal technique using OpenCV (Open Source Computer Vision Library). The proposed method utilizes image processing algorithms to detect and correct red-eye artifacts in digital images. We discuss the process of red-eye detection, the techniques used for accurate localization, and the algorithm for removing the red-eye effect. The experimental results demonstrate the effectiveness of the proposed method in automatically and efficiently eliminating red-eye artifacts from photographs. Finally, we discuss potential applications and future directions for research in automatic red-eye removal using OpenCV.


background image

Automatic Red Eye Remover using OpenCV

Primbetov Abbaz

1

Tashkent University of Applied Sciences, Gavhar Str. 1, Tashkent 100149, Uzbekistan

abbaz0203@mail.ru

https://doi.org/10.5281/zenodo.10471681

Keywords:

OpenCV(Open Source Computer Vision Library), image classification

Annotation:

Red-eye is a common issue in flash photography that occurs when the camera flash reflects off the subject's
retina, resulting in a red or orange coloration in the eyes. Manual removal of red-eye can be time-consuming
and tedious, especially when dealing with a large number of images. This paper presents an automatic red-
eye removal technique using OpenCV (Open Source Computer Vision Library). The proposed method utilizes
image processing algorithms to detect and correct red-eye artifacts in digital images. We discuss the process
of red-eye detection, the techniques used for accurate localization, and the algorithm for removing the red-
eye effect. The experimental results demonstrate the effectiveness of the proposed method in automatically
and efficiently eliminating red-eye artifacts from photographs. Finally, we discuss potential applications and
future directions for research in automatic red-eye removal using OpenCV.

1 INTRODUCTION

When you are in a dark room, your pupils are

dilated (enlarged) to let in more light to help you see
better. The flash on most cameras is very close to the
lens. When you take a picture with the flash on, the
light from the flash passes through the enlarged pupil
to the back of the eyeball and back out through the
pupil into the lens of the camera. The back of the
eyeball is called the fundus. It is red in color because
of an ample supply of blood in the fundus.

In recent years, computer vision and image

processing techniques have made significant
advancements, offering powerful tools to tackle
various image enhancement tasks. OpenCV (Open
Source Computer Vision Library) is a widely used
open-source library that provides a comprehensive
suite of algorithms and functions for image
processing and analysis. Leveraging the capabilities
of OpenCV, researchers and developers have
developed automated methods to detect and rectify
red-eye artifacts in digital images.

The objective of this paper is to present an

automatic red-eye remover using OpenCV. We aim
to explore the techniques and algorithms employed in
red-eye detection, localization, and removal while

utilizing the functionalities offered by the OpenCV
library. By leveraging the computational power and
versatility of OpenCV, we can develop an efficient
and accurate solution for eliminating red-eye effects
from photographs.

2 Red-Eye Detection and

Localization

Red-eye detection and localization play a crucial

role in automatically identifying the presence and
location of red-eye artifacts within digital images.
Accurate detection and localization are essential for
effectively removing the red-eye effect and restoring
the natural appearance of the subject's eyes. In this
section, we will discuss the underlying mechanisms
and methodologies used in red-eye detection and
localization.

The first step is to detect eyes automatically. We

use

the

standard

OpenCV

Haar

detector

(haarcascade_eye.xml) for eyes for finding the eyes.
Sometimes it makes sense to run a face detector first
and then detect the eyes inside the face region. To
keep things simple, we are run the eye detector


background image

directly on the image. Skipping the face detector
works when the input image is a portrait shot, or you
have a closeup of the eyes.

Next, we need to find the part of the pupil that is

affected by the red eyes. There are many different
ways of finding something red. One thing to note is
that our color is not just red, it is bright red! You could
convert the image to HSV color space and threshold
based on hue and brightness. In this post, we have
used a simpler heuristic. We say that he red channel
should be greater than a threshold and also the sum of
green and blue channels. For the purpose of a proof-
of-concept system, the heuristic is adequate, but if
you want to build automatic red-eye reduction for a
commercial software package, you would need to
gather thousands of images red eyes to come up with
something better.

Figure 1:

Left: Color-based pupil mask. Center:

Pupil mask with holes filled. Right: Dilated pupil

mask

The mask created in the previous step will most

likely have holes. The left image in the figure above
shows the raw mask obtained using color processing.

3

Red-Eye Removal Algorithm

Now we have a mask that contains only the red

region of each eye. We next show how to process the
area inside this mask to fix red eyes.

We know that red eyes saturate the red channel in

the image. In other words, all information in the red
channel is destroyed. How can we recover some of
this information back? While fixing red-eyes, we do
not need to retrieve the true underlying texture in the
red channels; we only need to find a texture that is
plausible.

Fortunately, the red-eye effect destroys the texture

only in the red channel; the blue and the green
channels are still good. You can see this in the figure
below where the red, green and blue channels of the
image are shown.

Figure 2. Left: Red channel. Center: Blue

channel. Right: Green channel.

A combination of the green and blue channels can be
used to come up with a plausible red channel. For

example, we can create a red channel which is the
average of the green and blue channels in the image.
However, doing this may give the pupil a slight tinge
which may look ok, but not great. Notice the purple
tinge in the center image.

Figure 3. Left: Red eye. Center: Fixed by replacing
red channel. Right: Fixed by replacing all channels.

That brings us to an important question. What should
be the color of the pupil? The pupil is an opening in
the eye, and the inside of the eye is completely dark.
The pupils should, therefore, be colorless (grayscale)
and dark. Instead of replacing only the red channel in
the pupil region, we replace all the channels with the
mean of the green and the blue channels. This
eliminates the purple tinge. The last step is to merge
the three channels to create our RGB image and then
put this fixed eye region back in the original image.

4

Experimental Results

Figure 4. Experimental result

Notice that removing all color from the pupil

region makes the image look pretty because the dot in
the center of the eye is completely white. Also notice
that the on the boundary of the pupil, the redness


background image

fades, but we still capture this region because of the
dilation operation.

Next, we show the result on a closeup photo of the

eyes. If we had used a face detector, it would not have
detected a face, and the automatic eye detector would
not have worked.

Figure 5. Experimental result

CONCLUSIONS

The paper presents an automatic red-eye

removal technique using OpenCV. It covers the
process of red-eye detection and localization, as
well as the algorithm for removing the red-eye
effect. The second and third section explains how
to implement the proposed method using OpenCV,
including image classification, red-eye detection
and localization, and the red-eye removal
algorithm. The experimental results section
presents the performance red-eye removal, and a
computational efficiency analysis.

REFERENCES

[1]

Gasparini, F., & Schettini, R. (2018). Automatic red-
eye removal for digital photography. In Single-Sensor
Imaging (pp. 449-478). CRC Press.

[2]

Schettini, R., & Gasparini, F. (2009). Automatic red-
eye removal for digital photography. In Single-Sensor
Imaging: Methods and Applications For Digital
Cameras (pp. 429-457). CRC Press.

[3]

Vairamani, A. D. (2023). Detection and diagnosis of
diseases by feature extraction and analysis on fundus
images

using

deep

learning

techniques.

In

Computational Methods and Deep Learning for
Ophthalmology (pp. 211-227). Academic Press.

[4]

Saranya, P., Pranati, R., & Patro, S. S. (2023).
Detection and classification of red lesions from retinal
images for diabetic retinopathy detection using deep
learning models. Multimedia Tools and Applications,
1-21.

[5]

Smolka, B., Czubin, K., Hardeberg, J. Y., Plataniotis,
K. N., Szczepanski, M., & Wojciechowski, K. (2003).
Towards automatic redeye effect removal. Pattern
Recognition Letters, 24(11), 1767-1785.

[6]

Razmjooy, N., Ramezani, M., & Ghadimi, N. (2017).
Imperialist competitive algorithm-based optimization
of neuro-fuzzy system parameters for automatic red-
eye removal. International Journal of Fuzzy Systems,
19, 1144-1156.

References

Gasparini, F., & Schettini, R. (2018). Automatic red-eye removal for digital photography. In Single-Sensor Imaging (pp. 449-478). CRC Press.

Schettini, R., & Gasparini, F. (2009). Automatic red-eye removal for digital photography. In Single-Sensor Imaging: Methods and Applications For Digital Cameras (pp. 429-457). CRC Press.

Vairamani, A. D. (2023). Detection and diagnosis of diseases by feature extraction and analysis on fundus images using deep learning techniques. In Computational Methods and Deep Learning for Ophthalmology (pp. 211-227). Academic Press.

Saranya, P., Pranati, R., & Patro, S. S. (2023). Detection and classification of red lesions from retinal images for diabetic retinopathy detection using deep learning models. Multimedia Tools and Applications, 1-21.

Smolka, B., Czubin, K., Hardeberg, J. Y., Plataniotis, K. N., Szczepanski, M., & Wojciechowski, K. (2003). Towards automatic redeye effect removal. Pattern Recognition Letters, 24(11), 1767-1785.

Razmjooy, N., Ramezani, M., & Ghadimi, N. (2017). Imperialist competitive algorithm-based optimization of neuro-fuzzy system parameters for automatic red-eye removal. International Journal of Fuzzy Systems, 19, 1144-1156.

inLibrary — это научная электронная библиотека inConference - научно-практические конференции inScience - Журнал Общество и инновации UACD - Антикоррупционный дайджест Узбекистана UZDA - Ассоциации стоматологов Узбекистана АСТ - Архитектура, строительство, транспорт Open Journal System - Престиж вашего журнала в международных базах данных inDesigner - Разработка сайта - создание сайтов под ключ в веб студии Iqtisodiy taraqqiyot va tahlil - ilmiy elektron jurnali yuridik va jismoniy shaxslarning in-Academy - Innovative Academy RSC MENC LEGIS - Адвокатское бюро SPORT-SCIENCE - Актуальные проблемы спортивной науки GLOTEC - Внедрение цифровых технологий в организации MuviPoisk - Смотрите фильмы онлайн, большая коллекция, новинки кинопроката Megatorg - Доска объявлений Megatorg.net: сайт бесплатных частных объявлений Skinormil - Космецевтика активного действия Pils - Мультибрендовый онлайн шоп METAMED - Фармацевтическая компания с полным спектром услуг Dexaflu - от симптомов гриппа и простуды SMARTY - Увеличение продаж вашей компании ELECARS - Электромобили в Ташкенте, Узбекистане CHINA MOTORS - Купи автомобиль своей мечты! PROKAT24 - Прокат и аренда строительных инструментов