Report Part 2
Report Part 2
CHAPTER 1
INTRODUCTION
A cataract is a white cloud formation that gradually hardens and forms a yellow
sheet on the normally transparent lense of the eye. This condition which leads to
decrease in the vision of a healthy eye is caused as the light does not reach the retinal
as the eye lens is covered by a hardened white cloud. The World Health
Organization conducted a survey a world sight day 2019 under which 36 million
people were identified as lined and 217 million had moderate or severe distance
vision impairment(MSVI),out of these cases of blindness and MSVI about 65 million
people were affected by cataract. Thus, cataract is responsible for 48% of blindness
cases.
The system should be able to analyse various types of eye images and identify signs
of cataracts, clouding on the lens. The solution should assist ophthalmologists in
early diagnosis and improve patient outcomes by enabling timely treatment.
1.Visual acuity test: The current system of conventional practices followed to detect
cataracts or other similar diseases includes a visual acuity test under which the
eyesight of the patient is checked with the help of a chart or a viewing device that
has letters in decreasing order of its size.
2.Slit-lamp examination: This detection technique helps to check the vision accuracy
of the patient another method which is majorly used by the doctors and
ophthalmologist is slit lamp examination to see the structure of the front of the eye
with the bright illumination of the light on the cornea, iris ,and lens all under high
magnification.
Dept. of IT
Cataract Detection
This system leverages advanced computer vision and artificial intelligence for
automated cataract detection from eye images. It reads the input image, resizes it,
and reduces noise before using a pre-trained Haar Cascade classifier to detect the
eye region. The HoughCircles method identifies lens areas, and average grayscale
intensity evaluates cataract presence and severity. Results are displayed as a
diagnostic message overlayed on the image, aiding in early and accurate detection.
1.4 Scope
This website can be used for early detection of cataract ,it can be accessed even in
the rural areas where there are no ophthalmologists. By using this they can diagnose
and go for, further appointment with optometrist. The system is intended as a
diagnostic aid, not a replacement for a qualified ophthalmologist's diagnosis and
treatment plan. Everytime we upload we use this site it stores the images which are
uploaded these can be used for further study and improvement of the project.
CHAPTER 2
Dept. of IT
Cataract Detection
Dept. of IT
Cataract Detection
CHAPTER 3
SYSTEM DESIGN
Dept. of IT
Cataract Detection
3.1 Methodology
The Haar Cascade Classifier is a machine learning-based approach used for object
detection. In this project, it detects eyes in grayscale images. The classifier is trained
on a dataset containing positive samples (images with eyes) and negative samples
(images without eyes). During training, it learns features like Haar-like features
(edges, lines, and rectangles) that distinguish eyes from non-eyes. The classifier
operates as a series of hierarchical stages (cascade), where each stage eliminates non-
eye regions more aggressively using learned features. It uses parameters like
scaleFactor, minNeighbors and minSize to refine the detection accuracy and speed.
The project uses a pre-trained Haar Cascade classifier (cv2.CascadeClassifier).
The Hough Circle Transform in the cataract detection code identifies circular regions
corresponding to the eye lens from grayscale images. It employs gradient-based edge
detection and accumulator voting to locate circles based on defined parameters like
edge thresholds and circle center detection. Detected circles are drawn on the
original image for visualization and further evaluation. This transform plays a
pivotal role by pinpointing potential cataract areas, enabling subsequent analysis of
grayscale intensity within these circles. Ultimately, it facilitates automated diagnosis
and assessment of cataract presence and severity, enhancing diagnostic accuracy and
aiding in timely medical intervention.The average grayscale intensity is then
compared against a threshold (in this case, 120). If the average intensity is below
this threshold, it indicates a lower likelihood of cataract ("Not Cataract"). If it
exceeds the threshold, the severity is quantified based on the percentage of intensity
relative to the maximum intensity (255).
Import Libraries: Load the necessary libraries, including OpenCV for image
processing and numpy for numerical operations.
Dept. of IT
Cataract Detection
Load Haar Cascade: Load a pre-trained Haar Cascade classifier for detecting eyes in
the image.
Read Image: Read the input image in both BGR (color) and grayscale formats.
Resize and Preprocess: Resize the image based on its dimensions to standardize the
size and apply median blurring to reduce noise.
Detect Eyes: Use the Haar Cascade classifier to detect eye regions in the grayscale
image.
Check Eye Detection: If no eyes are detected, terminate the process. If eyes are
detected, proceed to the next step.
Detect Circles: Use the Hough Circle Transform to detect circular regions (potential
cataract areas) within the detected eye regions.
Check Circle Detection: If no circles are detected, terminate the process. If circles are
detected, proceed to the next step.
Evaluate Cataract: Calculate the average grayscale intensity within the detected
circular regions to assess the presence and severity of cataracts.
Display Result: Overlay the diagnostic message on the image indicating whether a
cataract is detected and its severity percentage, then display the final result.
Dept. of IT
Cataract Detection
Class Diagram
Dept. of IT
Cataract Detection
Dept. of IT
Cataract Detection
Sequence Diagram
CHAPTER 4
Dept. of IT
Cataract Detection
Installing python
1.To download and install python visit the official website of python and choose
your version
2.Once the download is complete,run the exe for install Python.Now click on
Install Now.
4.When it finishes,you can see a screen that says the Setup was successful.Now
click on ”close”.
Installing VS code
Dept. of IT
Cataract Detection
2.The VSCode exectable file is downloaded Double-Click and strst the installation
by selecting the installation by selecting the installation path and agreeing to the
terms of installation.
Installing Docker
1.Visit the official Docker website and download Docker Desktop for Windows.
Dept. of IT
Cataract Detection
2. After the installation is complete, launch Docker Desktop from the Start menu.
3. Open a command prompt and run docker --version to verify that Docker is
installed and running.
4. Docker Desktop should start automatically. If it does not, you can start it
manually from the Start menu.
Capture or obtain eye images from a camera or a dataset .Prepare the images for
analysis, including resizing, normalization, and noise reduction. Identify and extract
relevant features from the eye images. Use rule based Artificial Intelligence to classify
or detect conditions or features in the eye images. Display or save the results.
4.3 Results
Dept. of IT
Cataract Detection
Dept. of IT
Cataract Detection
2.
3.
Dept. of IT
Cataract Detection
4.
5.
Dept. of IT
Cataract Detection
CHAPTER 5
The future enhancement is uilize CNNs to analyze high-resolution images of the eye,
specifically targeting the lens area. CNNs are excellent at detecting subtle patterns
and features within images, potentially improving the accuracy of cataract detection.
Develop a hybrid model that combines the strengths of the existing rule-based
system with CNNs. The rule-based system can handle initial screenings and
straightforward cases, while the CNN can handle more complex image analysis
tasks. Train the CNN on a large and diverse dataset of labeled ophthalmic images
to ensure the model generalizes well across different populations and conditions.We
can further take the location of user and suggest them places for medical treatment.
REFERENCES
Dept. of IT
Cataract Detection
3. M. Chew et al., "Estimates of visual impairment and its causes from the
national eye survey in Malaysia (NESII)", PLoS One, vol. 13, no. 6, pp. 1-11,
2018.
4. C. W. See, M. Iftikhar and F. A. Woreta, "Preoperative evaluation for
cataract surgery", Current Opinion in Ophthalmology, vol. 30, no. 1, pp. 3-
8, Jan. 2019.
Dept. of IT
Cataract Detection
import cv2
import numpy as np
class CataractDetector:
def __init__(self):
pass
Dept. of IT
Cataract Detection
average_color = inside.mean()
cataract_percentage = (average_color / 255) * 100
if average_color <= 120:
return "Not Cataract"
else:
return f"Cataract, {cataract_percentage:.2f}%"
cv2.imwrite(output_path, img_bgr)
# Removed the lines below to avoid GUI issues in headless
environments
# cv2.imshow('Cataract Detection', img_bgr)
# cv2.waitKey(0)
Dept. of IT