0% found this document useful (0 votes)
5 views19 pages

Report Part 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views19 pages

Report Part 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Cataract Detection

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.

1.1 Problem Statement

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.2 Existing System

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

3.Retinal exam: Another method is a retinal exam in which using a slit-lamp or an


ophthalmoscope, the doctor examines the lens for signs of cataract . The pupil is
made to stretch out a little wider than usual by making use of a suitable eye drop.

1.3 Proposed System

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

SYSTEM REQUIREMENT SPECIFICATIONS

Dept. of IT
Cataract Detection

2.1 Software Requirements

2.1.1 Functional Requirements

● The web application must be compatible any operating system


● The development and debugging of the application must utilize Visual Studio,
Visual Studio Code (VS Code), PyCharm etc.
● Visual Studio, Visual Studio Code, PyCharm provides an integrated
development environment (IDE) that supports Python and Flask, facilitating
efficient coding and debugging.
● The web application must be developed using Python.
● The backend framework must be Flask. Flask is a lightweight and versatile
framework suitable for building web applications.

2.1.2 Non-Functional Requirements

● The application must be deployable using Docker containers to ensure


consistent environments across development, testing, and production stages.
● The web application must respond to user actions within 5 seconds.
● Ensure that application can support multiple users simultaneously without
performance degradation.

2.2 Hardware Requirements

● Development Environment: Dual-core CPU, 8 GB RAM, 256 GB SSD,


Windows 10 or Ubuntu 18.04+.
● Production Environment: Quad-core CPU, 8 GB RAM (scalable), 256 GB
SSD, 1 Gbps Ethernet, Windows Server 2016+ or Ubuntu Server 18.04+.

2.3 System Architecture /Block Diagram

Dept. of IT
Cataract Detection

Fig 2.3.1: System Architecture

CHAPTER 3

SYSTEM DESIGN

Dept. of IT
Cataract Detection

3.1 Methodology

3.1.1 Algorithms Description

1. Haar Cascade Classifier

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).

2.Hough Circle Transform

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.

3.2 Structural Diagram

Dept. of IT
Cataract Detection

Class Diagram

Fig 3.2.1: Class Diagram

3.3 Behavioural Diagrams

Dept. of IT
Cataract Detection

Use Case Diagram

Fig 3.3.1: User Diagram

Dept. of IT
Cataract Detection

Sequence Diagram

Fig 3.3.2: Sequence Diagram

CHAPTER 4

RESULTS AND DISCUSSION

Dept. of IT
Cataract Detection

4.1 Environmental setup

Installing python

1.To download and install python visit the official website of python and choose
your version

Fig 4.1.1 Installing python

2.Once the download is complete,run the exe for install Python.Now click on
Install Now.

3.You can see Python Installing at this point.

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

Fig 4.1.2 Installing Vs Code

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.

3.After successful completion of VSCode installation.InstallPython and select the


installed python as an interpreter in VSCode.

Installing Docker

1.Visit the official Docker website and download Docker Desktop for Windows.

Fig 4.1.3 Installing Docker

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.

4.2 Implementation Details

System and implementation

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

Fig 4.3.1 Image 1

Fig 4.3.2 Image 2

4.4 Test cases

Dept. of IT
Cataract Detection

Input Expected output Test Results


1. Yes No

2.

3.

Dept. of IT
Cataract Detection

4.

5.

Fig 4.4.1 Test Cases

Dept. of IT
Cataract Detection

CHAPTER 5

CONCLUSION AND FUTURE ENHANCEMENTS


In this project, we developed and implemented a rule-based algorithm for the
detection of cataracts. Our approach focused on utilizing specific diagnostic criteria
and clinical features associated with cataracts to formulate a set of rules that can
accurately identify the presence of this eye condition. One of the significant
advantages of our rule-based system is its simplicity and ease of interpretation.
Medical professionals can easily understand and modify the rules based on evolving
clinical insights or new research findings. While there are areas for improvement and
enhancement, the current system lays a solid foundation for future advancements in
automated eye care diagnostics. While our algorithm can assist in the initial screening
and detection of cataracts, a comprehensive eye examination conducted by a
medical professional remains essential for accurate diagnosis and appropriate
treatment planning.

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

1. "Blindness and vision impairment", World Health Organization, Dec. 2021,


[online] Available: https://www.who.int/news-room/fact
sheets/detail/blindness-and-visual-impairment.

2. Z. Q. Ik, S. L. Lau and J. B. Chan, "Mobile cataract screening app using a


smartphone", 2015 IEEE Conference on e-Learning e-Management and e-
Services (IC3e), pp. 110-115, Aug. 2015.F. L.

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.

5. H. Liu, A. Gegov and F. Stahl, "Categorization and Construction of Rule


Based Systems", Commun. Comput. Inf. Sci., vol. 459 CCIS, pp. 183-194,
2014.

APPENDIX A: Source/Pseudo code

Dept. of IT
Cataract Detection

import cv2
import numpy as np

class CataractDetector:
def __init__(self):
pass

def read_image(self, filepath: str):


img_bgr = cv2.imread(filepath, cv2.IMREAD_COLOR)
img_gray = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
return img_bgr, img_gray

def detect_eye(self, img_gray):


eye_cascade = cv2.CascadeClassifier(cv2.data.haarcascades +
'haarcascade_eye.xml')
eyes = eye_cascade.detectMultiScale(img_gray, scaleFactor=1.1,
minNeighbors=5, minSize=(30, 30))
return eyes

def resize_and_preprocess(self, img_gray, img_bgr):


target_size = (500, 500)
img_gray = cv2.resize(img_gray, target_size,
interpolation=cv2.INTER_CUBIC)
img_gray = cv2.medianBlur(img_gray, 5)
img_bgr = cv2.resize(img_bgr, target_size,
interpolation=cv2.INTER_CUBIC)
factor = 300 # This can be adjusted based on the new size if
needed
return img_bgr, img_gray, factor

def detect_and_draw_circles(self, img_gray, img_bgr, factor):


circles = cv2.HoughCircles(img_gray, cv2.HOUGH_GRADIENT, 1, factor,
param1=50, param2=30, minRadius=0, maxRadius=0)
if circles is not None:
circles = np.uint16(np.around(circles))
for circle in circles[0]:
# Draw circles
cv2.circle(img_bgr, (circle[0], circle[1]), circle[2], (0,
255, 0), 2)
cv2.circle(img_bgr, (circle[0], circle[1]), 2, (0, 0, 255),
3)
return circles

def evaluate_cataract(self, img_gray, circles):


xc, yc, r = circles[0][0]
y, x = np.ogrid[:img_gray.shape[0], :img_gray.shape[1]]
mask = (x - xc) ** 2 + (y - yc) ** 2 > r ** 2
inside = np.ma.masked_where(~mask, img_gray)

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}%"

def detect_cataract(self, filepath: str, output_path: str):


img_bgr, img_gray = self.read_image(filepath)
img_bgr, img_gray, factor = self.resize_and_preprocess(img_gray,
img_bgr)
eyes = self.detect_eye(img_gray)
flag = False
message = "No Eyes Detected"
if len(eyes) > 0:
# If eyes are detected, proceed with cataract detection
circles = self.detect_and_draw_circles(img_gray, img_bgr,
factor)
if circles is not None:
message = self.evaluate_cataract(img_gray, circles)
font = cv2.FONT_HERSHEY_SIMPLEX
font_scale = 2 # Increase font scale for larger text
thickness = 4 # Increase thickness for bolder text
cv2.putText(img_bgr, message, (10, 50), font, font_scale,
(255, 255, 255), thickness, cv2.LINE_AA)
print(message)
flag = True
else:
print("No circles detected.")

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)

return message if flag else "No Eyes Detected"

Dept. of IT

You might also like