effect of heat treatment on eye using thermogram: a comprehensive analysis

101
Ngee Ann Polytechnic Electronic and Computer Engineering Division PDD2 Final Year Project Report Year 2011 PROJECT TITLE Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis TEAM MEMBERS 10076200C CHAN WEI YAN 10076198A MUHAMMAD ZULFADLY B ABDUL M 10075607A ZAR LI WIN NAING LOCATION 08-03-0004

Upload: muhd-zulfadly

Post on 16-Jul-2016

7 views

Category:

Documents


1 download

DESCRIPTION

Final Year (group) Project done as part of graduation requirement.

TRANSCRIPT

Page 1: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Ngee Ann Polytechnic

Electronic and Computer Engineering Division

PDD2

Final Year Project ReportYear 2011

PROJECT TITLE

Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

TEAM MEMBERS

10076200C CHAN WEI YAN10076198A MUHAMMAD ZULFADLY B ABDUL M

10075607A ZAR LI WIN NAING

LOCATION

08-03-0004

SUPERVISOR

ACHARYA RAJENDRA UDYAVARA

Page 2: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Title Page:

Project title: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Team Members: Chan Wei Yan S10076200C

Muhammad Zulfadly Bin Abdul Manap

S10076198A

Zar Li Win Naing S10075607A

Project Group: P602

Supervisor: Dr. Acharya Rajendra Udyavara

Affliation: NGEE ANN POLYTECHNIC

School of Engineering

Electrical and Computer Engineering Division

Biomedical Engineering

Collaboration: Singapore Eye Research Instititute (SERI)

Page 3: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Contents

Acknowledgement

1 – Abstract..................................................................................................Page 5

2 - Project Statement...................................................................................Page 6

3 - Project Objectives .................................................................................Page 6

4 - Background Information 4.1 Human eye: How our eyes see......................................................Page 7

4.2 Tear film.........................................................................................Page 8-9

4.3 Tears...............................................................................................Page 9

4.4 Dry Eye Syndrome.......................................................................Page 9-10

4.5 Meibomian Gland.....................................................................Page 10 -11

4.6 Heat Treatment...............................................................................Page 11

4.7 EyeGiene® System..........................................................................Page 12

4.8 Infrared Imaging..............................................................................Page 13

5 – Project Requirement................................................................................Page 14

Equipment Set-up...................................................................................Page 14

6 – Experimental Procedure.........................................................................Page 15

7 – System Block Diagram

Proposed Project Flow Chart.............................................................Page 16

8 - Data Analysis

8.1 - Proposed Method..........................................................................Page 17

8.2 - Proposed Implementation Flow Chart...........................................Page 17

8.3 – Implementation Details.................................................................Page 18

Page 4: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

8.3.1 -Semi-Automated Method........................................................Page 18

8.3.1.1 - Algorithm for Semi-Automated Method.................Page 19-22

8.4 - Batch Processing...................................................................Page 22-23

8.5. Statistical Texture Analysis......................................................Page 23-24

8.5.1 Fractal Dimension.............................................Page 24-25

8.5.2 Laws Masking Energy.......................................Page 25-26

8.5.3 Local Binary Pattern..........................................Page 26-27

8.6 Statistical Analysis

8.6.1. ANOVA..................................................................Page 28

9 – Verification & Evaluation

9.1 Experimental Results........................................................................Page 29

9.1.1 Results with Semi-automated method

9.1.1.1 Statistical Results.....................................................Page 29-30

9.1.2 Results with Automated method.............................................Page 31

9.1.2.1 Results with Fractal Dimension...............................Page 31-32

9.1.2.2 Results with Laws Masking Energy..........................Page 33-37

9.1.2.3 Results with Local Binary Pattern.............................Page 38-42

9.1.3 Results without Eye Mask...........................................................Page 43

10 - GUI Development...............................................................................Page 44-46

11 - Discussion

11.1 Summary of Work Done..............................................................Page 47

12 - Conclusion .............................................................................................Page 48

13 - Problems and Solution........................................................................Page 49-50

14 - References.........................................................................................Page 51-53

Appendices...........................................................................Page 54 onwards

Page 5: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Acknowledgement

We would like to acknowledge and extend my heartfelt gratitude to the following

persons who have made the completion of this final report possible: 

Dr. Acharya Rajendra Udyavara (Ngee Ann Polytechnic]: Our project supervisor for

his vital encouragement, assistance and support. Not to forget the constant

reminders, much needed motivation and the inspiration he extended during our one

year project period.

Dr Tan Jen Hong (Ngee Ann Polytechnic]: For his assistance in collection of data for

our project.

Volunteers: For sacrificing their time to take part in our experiment.

Page 6: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1 - Abstract

Our eyes are perhaps one of the most important sense organ in the human

body. Without the eyes, we would not be granted vision. Our eyes are also able to

detect changes in light and colours. However, our eyes are susceptible to number of

diseases. Although non-life threatening, disease like cataract, for example, hinders

our vision.

Warm compression therapy is one of the effective treatments of dry eye

caused by Meibomian Glands dysfunction. It helps soothe the oil flow from the

glands which would eventually replenish the depleting lipid layer of the cornea;

Resulting in drop of corneal surface temperature (CST). Our aim is to verify the

effects of heat treatment through various method of image processing.

10 volunteers were subjected to the heat treatment experiment carried out in

Singapore Eye Research Institute (SERI) under controlled environmental

condition(s); ambient temperature, Volunteer’s body temperature and humidity rate

were recorded. Another 7 volunteers were subjected to a controlled experiment

whereby they had to undergo the exact same procedure in the absence of the heat

treatment

With help of equipments like the VarioTHERM camera to obtain thermograms

of our subjects, these obtained images (thermograms) will undergo processes of

various Image analysis techniques. Statistical analysis will be done to calculate the

overall mean of each texture features. These mean will be plotted in the form of bar

graphs in Excel spreadsheet to study the trend of temperature changes.

With the graph yield from excel, we were able to observe a trend in

temperature changes; thus, identifying the significance of the heat treatment.

5

Page 7: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

2 - Project Statement

Analyse of effect of heat treatment for patient with dry eyes using Image

analysis techniques notably Semi-automated method, Laws Masking Energy (LME),

Fractal Dimension (FD) and Local Binary Pattern (LBP).

3 - Project Objective

Our primary objective is to study the effects of heat treatment on the eyes with

the initial assumption that the heat treatment will cause a rise in corneal surface

temperature (CST) and eventually a drop in CST an hour after the heat treatment is

applied (depleted lipid layer in cornea is replenished).

This will be done using image analysis techniques on obtained to determine

corneal surface temperature and features like fractal dimension etc. Statistical

Analysis will be done to evaluate our results to obtain a visual trend of temperature

changes by plotting graphs using excel sheets.

A Graphical User Interface (GUI) will be developed at the end to enable user

to calculate corneal surface temperature without full manual intervention.

6

Page 8: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

4 – Background Information

4.1 - Human Eye: How our eyes see

Light waves from an object enters through the cornea, makes its way through

the pupil and the colour iris (through circular opening). The Light waves will pass

through the lens located at the back of the pupils. Here, the lights rays will be

modified by the lens to focus on the retina. Located at the retina are the

photosensitive cells or photoreceptors (rod nerve cells and cones nerves cells).

These photoreceptors are connected to the optic nerves. The light waves (image)

are transmitted as electrical signal to the brains via the optic nerves (connected to

the brains).

Pupils regulate the amount of light passing through the eye – such as when

large amount of light passes through (very bright), the ciliary muscles will constrict

making the ‘hole’ smaller as to prevent damage to the photoreceptors located at the

back of the eye (retina and fovea centralis). Thus, dilation of the pupils is visible for

detection.

7

Page 9: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

4.2 - Tear film

Tear film is the outermost surface of the human eye; coating the eye. This

layer film remains directly exposed to the environment. Tear film, or also known as

pre-corneal film, is made up of 3 different layers. These 3 layers are important in

maintaining a good vision and eye health. This film is continuously doused with tears

to keep moist, protect from infections and assistance in wound healing.

The 3 layers are:

8

Page 10: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Lipid (oil) Layer: The outermost layer of the film. A Hydrophobic layer that

coats the aqueous layer thus preventing fast evaporation of the aqueous layer and

keeping it moist.

Aqueous layer: The middle layer. This is the layer where nutrients, water and

ions needed to moisturize and nourish the eyes are found. This layer also plays a

vital role in keeping eyes protected from infectious agents.

Mucin (mucous) layer: The lowest layer of the film. Hydrophilic layers which

helps in even distribution of tears. This layer covers the cornea and allows the tear

film to adhere to the eye surface.

4.3 – Tears

Maintenance of the cornea requires sufficient amount of tears. Our vision also

gets affected without the help of tears; it provides clear vision. Tears also have other

function: lubrication, reducing eye infection risk and washing away foreign matters

(dust and sand for example).

Tears are produced by the Lacrimal gland (or tear gland). Production of tears

is caused by emotions (crying) or by irritation.

4.4 - Dry eye syndrome

Dry eye condition occurs as a result of insufficient water (tears) in our eyes;

usually of biological (improper balance of tears production) or environmental

conditions. Thus the term ‘Dry eye’ refers to the dryness cause by the lack of moist.

Dry eye is an extremely common and hard-to-recognized disease.

Symptoms for dry eyes are: excruciating pain, redness of the sclera (white

part of the eye, surrounding cornea), itchiness, blurred vision or sensitivity to light.

There are various common causes for occurrence of dry eyes.

9

Page 11: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Aging: Dry eyes can occur as part of natural process of aging. Generally,

tears production decreases as we age. A person at the age of 65-years old will have

his/her tear production rate decreases to 40% as compared to when they are

younger (18-21 years old).

Systemic diseases: Dry eye syndrome is also result from medical conditions

such as Meibomian gland dysfunction, lacrimal gland dysfunction, Blepharitis,

diabetes or arthritis.

Environmental: Extreme weather conditions like wind/ air conditioner/dry

climates or exposure to smoke/dust could result fast evaporation rate; leading to

presence of symptoms.

Others: Hormonal changes (especially in women), prolonged use of contact

lens, chemical burns and Laser refractive surgery (LASIK).

However, in our project we are more interested in dry eyes caused by

Meibomian gland dysfunction.

4.5 - Meibomian Glands (Lipid layer abnormalities)

Meibomian glands are responsible for the supply/release of meibum.

Meibomian gland ducts are located along the margin of the eyelids. The duct

releases Meibum, a vital substance that prevents fast evaporation of the tear film to

prevent conditions like dry eyes.

10

Page 12: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Meibomian gland dysfunction is one of the main causes of dry eyes usually

when there is blockage in the narrow duct connecting the glands to the tear film. This

results in insufficient amount of oil being released into the tear film. Insufficient

amount of oil in the lipid layer of the tear film causes the fast evaporation of the water

layer. The rate of evaporation is to increase up 10 or 20 times in the absence of this

lipid layer. Poor quality of oil is also a result of swollen or plugged glands.

4.6 - Heat Treatment

Common treatment for patients with Dry Eye syndrome caused by Meibomian

gland dysfunction is by warm compression. The slight rise in temperature causes the

hardened oil to loosen; alleviating the clogged duct in the process. The thinning of

the oil ensures a smooth flow of the oil to the lipid layer of the tear film. Thickness of

the lipid layer increases. This layer plays an important role in tear evaporation rate

where if in sufficient amount, decreases the evaporation rate. Heat treatment also

improves one’s blood circulation albeit temporarily.

The required temperature of the heat treatment is specific. If temperature is

higher than required, the heat may burn our eyes/eyelid. If the temperature isn’t

warm enough, the hardened oil may not thin. The temperature of our eyelid has an

average range of between 32.7 and 33.1 Celsius.

11

Page 13: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

4.7 EyeGiene® Insta-WarmthTM System

EyeGiene® System is a product that specialises in warm compression

therapy. Most of the self-made warm compression method may not be effective. For

example, washcloth heated by microwave may be unsuitable due to high

temperature which renders our eyes vulnerable to injuries. Moreover, if left to cool,

the warmth treatment may be ineffective.

The disposable warming unit can be active with ease (pressing for 30 seconds) and

fitted into the slots of the EyeGiene® Eye Mask. The warming is designated to reach

an optimal temperature of 40 degree Celsius; at this temperature, the hardened oil

starts to thin (for smooth flow). The mask is worn for about 10 minutes before

removal.

12

Page 14: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

4.8 - Infrared Imaging

Thermal imaging or Infrared imaging is an electromagnetic radiation used in

detection of radiation within the infrared frequencies. The temperature of ocular

surface is of a great interest in the field of ophthalmology. In general, the measured

surface temperatures are based on the detected infrared radiation;; no alteration of

surface temperature. Thermal Imaging is most used in Medical therapy; as part

diagnosis procedure. It is practically much safer as it is neither invasive or requires

any form of physical contact and doesn’t involve harmful radiation unlike X-rays or

Computed Tomography.

We can use infrared imaging to measure the ocular surface temperature as well as

detecting temperature changes and detection of any abnormalities. Radiation

emitted from the eyes is captured and recorded with an Infrared camera. The visual

image captured shows spectrum of colours which maps the skin/eye temperature.

The changes in spectrum of colours indicate the changes in emissivity of radiation

which in turns indicates changes in temperature. Thus, non-invasive detection of

abnormalities of cornea through infrared imaging enables easy and safer diagnosis

procedure.

The use of Infrared imaging technique in other medical field, for example, in early

detection of breast cancer and fever screening.

Normal eye Thermogram of normal eye

13

Page 15: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

5 - Project requirement

MATLAB R2007a Introduction to Digital Image Processing by Alasdair McAndrew Irbis Plus 2.2 Irbis Online 2.4 VarioTHERM VarioTHERM camera and equipment for capturing infrared images of the eye

5.1 - Equipment Set-up

14

Page 16: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

6 - Experimental Procedure 7.1 Data Collection Procedure

On June 28, 2011, we went down to National Eye Centre to collect our data, with

assistance of Dr. Tan Jen Hong.

The data of each test subjects were taken on 4 different intervals. Each recording

session lasted for 25 seconds.

1st interval: Baseline. Body and room temperature/humidity were recorded.

2nd interval: 20 minutes after the first interval.

After 2nd interval recording were taken, each subject will have to undergo heat

treatment. Each subject was required to put on eye mask with heating pad

(EyeGiene) for 5 minutes.

3rd interval: Immediately after eye mask removal.

4th interval: 1 hour after eye mask removal.

15

Page 17: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

7 - System Block Diagram

Proposed Project Flow Chart

16

Setting up of equipments (IR

camera)

Clinical Procedure (See data collection

procedure)

Thermography of subject's eyes taken

Image Analysis method (Semi-

automated method and texture analysis)

Data compilation on Excel spread with

mean and standard deviation

Page 18: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

8- Data Analysis

8.1 Proposed Method

With the data (images) obtained from Singapore Eye Research Institute

(SERI) database, we will develop algorithms both (semi-automated and fully

automated) and implement these to our thermograms to verify the heat changes and

record the trend of ocular surface temperature changes.

8.2 Proposed Implementation Flow Chart

1. Semi-Automated method - Detection of corneal region and finding average

corneal surface temperature (CST).

2. Statistical Texture Analysis – Implementation of various image texture analysis

method : Fractal Dimension (FD), Law’s Masking Energy (LME) and Local Binary

Pattern (LBP)

3. Statistical Analysis – Data compilation; Calculating average values of respective

parameter: CST, FD, LME, LBP with standard deviation. Plotting of graphs in

Microsoft Excel to obtain visual trend.

17

Semi-Automated

Method

Statistical Texture Analysis

Statistical Analysis

Page 19: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

8.3 Implementation Details

8.3.1 -Semi Automated Method

Semi-automated method requires the use of MATLAB Image Processing Toolbox

(version R2007a) software with the aid “Introduction to Digital Image Processing”).This

software is particularly useful for image-processing. The thermograms to be processed

must be converted to JPEG format (from .bmp format).

Using this method, an algorithm is developed to extract the pixel count in the

obtained thermograms. The average numerical pixel value will be implemented in a

formula that will yield the numerical value of the corneal surface temperature.

There are 5 steps to the Semi-automated method.

Step 1: Conversion of the obtained ocular thermogram from RGB into grey-scale

images. Grey-scale thermograms are useful for quantitive analysis.

Step 2: The now grey-scale thermogram will undergo cropping. Unwanted region of

thermogram is cut off, isolating the desired areas. Once cropping is done, image is

resized to the desired dimension of 200 by 400. This step requires manual

intervention.

Step 3: Creating a region of interest (a circle) to fit the cornea as we want to calculate the

average pixel amount of the cornea solely.

Step 4 : Applying the region of interest to the image, focusing on the cornea

Step 5: Calculating the average pixel value which will be used to find the temperature of

cornea using the equation:

Temperature=[[(pixel)*(36-32)]/255]+32

18

Page 20: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

8.3.1.1 – Algorithm for Semi-Automated Method

Step 1: Conversion of RGB image to greyscale

Q = rgb2gray(imread(‘image name’)); % conversion of RGB to greyscale

imshow(Q) % to show greyscale image

Step 2: Cropping and resizing

e2 = imcrop(e,[ rect ]); % to crop the desired area of the image, where rect is the

desired area coordination

figure,imshow(e2) % Show cropped image

e3=imresize(e2,[200 400]); % Resize the cropped image to standard 200 by 400

imshow(e3) % Show the resized image

19

Page 21: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Step 3: Creating a circle ROI (Region of Interest)

[y1, x1]=size(e3); % Declare the y and x axis values as 200 and 400 respectively

r=x1/4; %defining the radius of cornea( one-quarter of total eye length)

N=256;

d=(0:N)*2*pi/N;

p=r.*cos(d)+x1/2;

q=r.*sin(d)+y1/2;

qw1=roipoly(e3,p,q); % Define the region of interest (ROI)

qw=~qw1; % Complement of ROI

imshow(bw1),figure,imshow(bw) % Show complement of ROI

Circular region of interest created

20

Page 22: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

ROI complement

Step 4: Application of the region of interest to the image

x1=fspecial('average', [100 100]);

h=imadjust(x1,[0,1],[1,0]);

e3roi=roifilt2(x,e3,qw); % roi filter

imshow(e3roi) % Show roi filter

21

Page 23: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Step 5: Calculate average pixel value and determine the temperature of cornea.

count=0; % Initialise count number to zero

m=0;

for i=40:150

for j=140:260

if e3roi(i,j)<255

count=count+1;

n=e3roi(i,j);

m=uint32(m)+uint32(n);

end

end

end

>> V=double(m)/count % Calculate average pixel

>> T=[[(p)*(36-32)]/255]+32 % calculate temperature of cornea.

8.4 - Batch Processing

Since we had 500 frames for every folder (8 folders for each subject, 2 for

each recordings) and time was not on our side. We had to create and implement

codes that will process the images in batches. We need to declare a variable that will

store our results and specify the folder of interest.

22

Page 24: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

%insert into step 1

Res = [];

fn = dir(fullfile(pwd,'*.jpg')); %specifies folders of images

for i = 1:length(fn) %Declare amount of images to be processed

close all;

a=rgb2gray(imread(fn(i).name)); % Read individual frames and convert to greyscale

%Insert after step 5

Res = [Res; p T]; % Stores results

end;

8.5 - Statistical Texture Analysis

In general, fixed repeated elements or pattern on a surface are known as

texture. Image textures are complicated visual patterns. It consists of entities or sub-

pattern regions of various characteristics (i.e. size, shape, colour, brightness, etc.)

Texture analysis is a class of mathematical procedure which extracts information by

characterizing spatial variations within an image.

Entities made up of groups of pixels or mutually related pixels can be

specified as texture. Every image contains pixels in general. Texture primitives or

texture elements are terms that define this group of pixels.

A statistical approach to texture analysis involves computation of different

properties. It is deem suitable if the pixel sizes are similar to the primitive sizes.

Examples of statistical texture analysis are convolution filter, Fourier transforms,

spatial autocorrelation fractals and co-occurrence matrix.

23

Page 25: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Statistical approach analyzes the spatial distribution of gray values. It is done

by computing local features at each point in the image. A set of statistics will be

derived from the distributions of the local features. Further classification of statistical

methods is dependent on the pixel count that constitutes the local feature; for

example, first-order statistic (one pixel), second-order statistic (two pixels) and

higher-order statistic (three or more pixels).

8.5.1- Fractal Dimension

Fractal describes geometric complexities that show self-similarity. A

comprehensive description of a geometric object’s complexity and irregularity can be

determined by fractal dimension. In a 2D space, an object has a fractal dimension

(D) in range of 0 – D – 2.

Fractal Dimension is encoded in natural texture which determines the

irregularity or surface roughness over multiple scales. Fractal dimension is a non

integer value of one measure of fractals. A large numerical fractal value denotes a

rougher texture.

For this project, we applied the box counting method. Box counting is a

method used to establish and estimating the fractal dimension of a two-tone image..

Box-counting dimension is based on pixel counts visited by the set(images) under

measurement in a grid of varying resolution and position. Box- counting method is

more practical in analysing non self-similar images as most real-life images are non

self-similar.

Box-counting method is given based the following equation:

D=log (N )

log (1r)

24

Page 26: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

In this method, a grid is applied to the images. Variable r is the x-axis of the

grid whereby r = 1/ (width of grid) e.g. if the grid is 120*300, r = 1/300. N is the

number of box in the grid that the picture touches. The whole process is repeated

with different sizes of boxes. It will yield a logarithmical function of box size (x-axis)

and number of boxes needed to cover fractal (y-axis). A graph on logarithmic scale

will be plotted with the obtained value. The slope obtained is referred as box

dimension, which is a suitable approximation of fractal dimension (D).

Image(s) to be implemented with box-method must be in greyscale format.

8.5.2 - Laws Masking Energy (LME)

Several features in image texture are vital in the process texture analysis.

Laws have identified features which are useful, notably: coarseness, density,

directionality, direction, frequency, linearity, phase, regularity, roughness and

uniformity.

By evaluating Average Gray Level, Edges, Spots, Ripples and Waves in

image textures; we can determine the texture properties. Laws texture energy

measures are derived from 3 simple vectors. L3 = (1, 2, 3) which represents

averaging; E3 = (-1, 0, 1) calculating first difference (edges); and S3 = (-1,2,-1)

corresponding to the second difference (spots). After

Convolution of these vectors with themselves and each other, five vectors result:

Level L5 = [1, 4, 6, 4, 1]

Edge E5 = [-1,-2, 0, 2, 1]

Spots S5 = [-1, 0, 2, 0,-1]

Ripples R5 = [1, -4, 6,-4, 1]

Waves W5 = [-1, 2, 0,-2,-1]

25

Page 27: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

These vectors are mutually multiplied, considering the first term as column

vector and second term as row vector, it will yield results in 5 X 5 Matrix. This is

known as Laws Mask.

A feature vector is derived from convolution of Law’s Mask with texture image

and calculation of energy statistics; which can be used for texture description.

8.5.3- Local Binary Pattern (LBP)

LBP (local binary pattern) is a simple powerful method of analyzing textures

which can show excellcent accurate results.In order to get LBP, we need grayscale

images and LBP can be obtained by multiplying the threshold values with weights

given to the corresponding pixels, and summing up the result.

Since LBP is a kind of measuring the changes in gray scale image, we need

the contrast measure (LBP/C) to derive. The average of the gray levels below the

center pixel is subtracted from that of the gray levels below(or equal to) the center

pixel.Two-dimentional distributions of the LBP and local contrast measures were

used as features.This operator was called LBP/C and very good discrimination rates

can be reported with textures selected from the photographic album.

26

Page 28: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

27

Page 29: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

8.6 - Statistical Analysis

8.6.1 - ANOVA

Translating gathered data is an important procedure in evaluation of whether

the information gather is valid. Statistical analysis allows analysis and interpretation

numerical or categorical biostatistics.

The data that were extracted from various automated method (i.e. FD, LME,

LBP) and semi-automated, are subjected to P-test using Analysis of Variance

(ANOVA). An average value along with standard deviation and difference of each

mean were computed which is then used to compare variances between each sets

(1st recording, 2nd recording etc.).

All 500 frames from each set of data were accounted for.

P-value indicates whether we should reject null hypothesis. An observation of

high difference between each individual set of data will yield an ideal P-value of

<0.0001; indicating a statistically significant results.

28

Page 30: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

9 - Verification and Evaluation

9.1 - Experimental Results

A total of 10 subject data were collected for this project; all obtained from

Singapore Eye Research Institute (SERI). Each subject has a total number 4,000

frame – 1,000 for one recording session (left and right eye) and there are 4 recording

session. The thermograms collected are of grey-scale format. The entire experiment

was carried out using MATLAB Image processing toolbox (R2007a).

These images will undergo various image analysis techniques to study the

temperature changes.

Time Point:

1st recording – Baseline

2nd recording – 20 minutes after baseline

3rd recording – Immediate after heat treatment

4th recording - 1 hour after heat treatment

9.1.1 - Results with semi-automated method

9.1.1.1 - Statistical Method

Semi-automated method will yield the average pixel value of the cornea. With this

value, the corneal surface temperature will be determined.

ANOVA (Analysis of Variance) are used to compute the mean and standard

deviation for sets of data for each subject. The data processed had a P-value of

<0.0001. The mean of all 10 subjects were also obtained (see Table 1a). With these

overall mean values, a bar graph was plotted using Microsoft Excel software (v2007)

to show the trend of temperature changes in each recording (see Table 1b).

29

Page 31: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Table 1a

1st 2nd 3rd 4th 32.8

33

33.2

33.4

33.6

33.8

34

34.2

34.4

Results(Semi-automated)

Tem

pera

ture

Table 1b

30

Average temperature (with standard deviation)

Recording Right eye Left eye

1st 33.82 ± 0.198 33.822 ± 0.155

2nd 33.733 ± 0.2 33.696 ± 0.189

3rd 34.195 ± 0.197 34.208 ± 0.252

4th 33.335 ± 0.313 33.346 ± 0.349

Page 32: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

9.1.2 - Results with Automated methodAutomated method is based on texture analysis. Various texture features are

extracted using 3 programmes: Fractal Dimension (FD), Laws Masking Energy

(LME) and Local Binary Pattern (LBP). FD will yield a single parameter while LME

and LBP have 8 and 9 respectively.

Again, obtained data from 10 subjects will undergo statistical analysis to obtain mean

and standard deviation. These values will be used to plot graphs using Microsoft

Excel software (v2007) for easier visual analysis.

Fractal Dimension increases as the ocular surface temperature decreases (4 th

recording). When temperature elevated, it decreases (see Table 2b). Similar patterns

were also observed in each of the parameters in LME (see Table 3a –i) and LBP

(see Table 4a – j) respectively.

9.1.2.1- Results with Fractal Dimension

Average Fractal Dimension

Recording Left Right

1st 1.9243 ± 7.550E-03 1.9285 ± 1.092E-02

2nd 1.9288 ± 9.810E-03 1.9324 ± 1.232E-02

3rd 1.9093 ± 1.372E-02 1.9167 ± 1.733E-02

4th 1.9392 ± 1.239E-02 1.9427 ± 1.089E-02

Table 2a

31

Page 33: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st Recording 2nd Recording 3rd Recording 4th Recording1.89

1.9

1.91

1.92

1.93

1.94

1.95

Results (Fractal Dimension)

Axis Title

Table 2b

32

Page 34: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

9.1.2.2 - Results with LME

1st 2nd 3rd 4th0

100000000

200000000

300000000

400000000

500000000

600000000

700000000

LME 1

Table 3a

1st 2nd 3rd 4th440000000

460000000

480000000

500000000

520000000

540000000

560000000

580000000

600000000

LME 2

Table 3b

33

Page 35: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th820000000

840000000

860000000

880000000

900000000

920000000

940000000

960000000

980000000

1000000000

LME 3

Table 3c

1st 2nd 3rd 4th0

5000000

10000000

15000000

20000000

25000000

30000000

LME 4

Table 3d

34

Page 36: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th0

5000000

10000000

15000000

20000000

25000000

30000000

35000000

40000000

45000000

LME 5

Table 3e

1st 2nd 3rd 4th840000000

860000000

880000000

900000000

920000000

940000000

960000000

980000000

1000000000

LME 6

Table 3f

35

Page 37: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th0

5000000

10000000

15000000

20000000

25000000

30000000

35000000

40000000

45000000

LME 7

Table 3g

1st 2nd 3rd 4th0

20000000

40000000

60000000

80000000

100000000

120000000

LME 8

Table 3h

36

Page 38: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 81st 2nd 3rd 4th

0

200000000

400000000

600000000

800000000

1000000000

1200000000

LME (Combined Results)

Table 3i

37

Page 39: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

9.1.2.3 - Results with LBP

1st 1st 1st 1st0

0.5

1

1.5

2

2.5

3

3.5

LBP 1

Axis Title

Table 4a

1st 2nd 3rd 4th0.046

0.048

0.05

0.052

0.054

0.056

0.058

0.06

LBP 2

Axis Title

Table 4b

38

Page 40: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th0.19

0.195

0.2

0.205

0.21

0.215

LBP 3

Axis Title

Table 4c

1st 2nd 3rd 4th0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

LBP 4

Axis Title

Table 4d

39

Page 41: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th0.104

0.106

0.108

0.11

0.112

0.114

0.116

0.118

0.12

0.122

0.124

LBP 5

Axis Title

Table 4e

1st 2nd 3rd 4th0.305

0.31

0.315

0.32

0.325

0.33

LBP 6

Axis Title

Table 4f

40

Page 42: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th0

1

2

3

4

5

6

7

LBP 7

Axis Title

Table 4g

1st 2nd 3rd 4th0.142

0.144

0.146

0.148

0.15

0.152

0.154

0.156

0.158

0.16

LBP 8

Axis Title

Table 4h

41

Page 43: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

1st 2nd 3rd 4th0.348

0.35

0.352

0.354

0.356

0.358

0.36

0.362

0.364

0.366

LBP 9

Axis Title

Table 4i

1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 91st 2nd 3rd 4th

0

1

2

3

4

5

6

7

Results (LBP Combined Results)

Axis Title

Table 4j

42

Page 44: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

9.1.3 - Results (without eye mask)

There were 7 volunteers whom participated in test without eye mask. This is a

controlled test carried out to prove the heating treatment did cause a rise in

temperature. In this session, there were only 3 recording interval; 3 rd recording was

omitted (immediate after heat treatment).

Time Point:

1st recording – Baseline

2nd recording – 20 minutes after baseline

4th recording – 1 hour after heat treatment

Average temperature

Recording Left Right

1st 33.35 ± 0.87 33.08 ± 0.90

2nd 33.73 ± 0.26 33.00 ± 0.89

4th 33.13 ± 0.62 33.77 ± 0.15

1st 2nd 4th32.6

32.8

33

33.2

33.4

33.6

33.8

34

Results (w/o eye mask)

Tem

pera

ture

43

Page 45: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

10 - GUI DevelopmentA Graphical User Interface or GUI was developed using MATLAB with the objectives

of

1) Enabling user(s) to calculate the average corneal surface

temperature (CST) with a simple pushbutton function.

2) Calculate values of fractal dimension and plot a 2-D graph on a

logarithmic scale. (Similar pushbutton function)

Functions:

Load Image - Loads image chosen specifically by user. Images must be in JPEG

format and which must be the already cropped image. Loaded image will be

displayed in the axes.

44

Page 46: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Average Temperature – This button is for calculating the average CST of the loaded

image. The results will be displayed in the box “Ave”.

function Average_Callback(hObject, eventdata, handles) global im; % Declare loaded image for general use

count=0; % Pixel count

m=0;

for i=40:150

for j=140:260

if im(i,j)<255

count=count+1;

n=im(i,j);

m=uint32(m)+uint32(n);

end

end

end

p=double(m)/count; % Find pixel value

T=[[(p)*(36-32)]/255]+32; % Find average temperature

Res = T; %Store temperature value in a new variable.

set(handles.Averagetext,'String',Res); %Displays temperature value as a string.

Fractal – This button is for calculating the fractal dimension (FD) of the cropped eyes

images. The result of the values will be shown in the box “Fractal”. And a logarithmic

scaled 2-D graph will be automatically plotted onto the second axes.

45

Page 47: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Reset – Clear all axes and texts

Quit – Terminates the program.

46

Page 48: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

11- Discussion

11.1 - Summary of Work Done

With the results obtained using Semi-automated method, our results showed

the anticipated trend of temperature changes. The temperature recorded at the 4 th

interval (1 hour after heat treatment) has shown a decrease lower than the

temperature at baseline interval. The heat treatment also displays it effectiveness at

the 3rd interval. Temperature elevation occurs at the 3rd interval. We were able to

show the trend visually by plotting a bar graph using Excel spreadsheet.

As for the controlled, the results showed a no trend of temperature change. 3rd

recording interval was omitted and the temperature at 4th does not decrease as

expected.

The mean of each extracted texture features also shows promising results.

The means at 4th recording are higher as compared to the first 2 recording. To add

on, the temperature increase at 3rd recording shows a decrease in the mean value;

verifying temperature change.

A simple GUI was developed at the end with the aim to help user to measure

corneal surface temperature along with fractal dimension with ease. This GUI can be

used for other purposes as well (non-invasive form of measuring corneal surface

temperature).

47

Page 49: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

12 - Conclusion Having completed our final year project with the necessary supported detailed

analysis, we were able to verify that the heat treatment is effective and that it aids

lowering down the eye temperature by replenishing the lipid layer of the cornea

(reduction in evaporation rate). It is further validated with the results of controlled and

texture analysis. Thus, we come to a general conclusion the heat treatment can be

used to treat patient with Meibomian Gland Dysfunction in the future.

The final year project has been a fruitful experience for our group. Apart from

hands-on experience on powerful software(s) like MATLAB and Microsoft Excel, we

learn the importance of teamwork.

Throughout the one year project period, there were ups and downs in terms

of morality and communications. Without a proper mindset and poor communication

between one another; a team is vulnerable to breakdown which will be unpleasant.

From this experience, we hope that we can use the knowledge we picked up

as a learning point for our future projects that we will encounter in further studies or

career.

48

Page 50: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

13 - Problems encountered/Solutions.

Problems with Software Algorithm

The first problems we encountered were the functions in MATLAB. The book

titled ‘Introduction to Digital Image Processing’ that we referred to during our

MATLAB practices was perhaps that some of the techniques taught in the book were

obsolete/doesn’t work. Thus, some function will cause MATLAB errors.

The second problem was that the accuracy of the results as the Semi-

automated method also involves tedious work of user input and also eyelashes

within region of interest affects the average pixel values. Thus, the temperature

value gets affected.

Another problem we faced with the semi-automated method were that this

method can only be implemented onto a greyscale image; making it necessary to

convert obtained images into greyscale, even if it has been converted into greyscale

before we processed it in MATLAB. Thus we had to display the images as greyscale

again before applying region of interest. Else, error will occur.

Solutions for Problems with Software Algorithm

To solve these problems, we seek help from our supervisor regarding certain

techniques/functions. We were told that some of the functions no longer exist or

were replaced with newer function. Moreover, the help directory in MATLAB enables

us to learn newer functions as to avoid confusion and clear our doubts.

49

Page 51: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Problems with GUI development

As we had the aims to create a simple GUI that could allows users to

calculate corneal surface temperature without much hassle. However, we were

halted with a problem. We could not create a pushbutton function that could directly

crop the corneal region from our original thermograms. Reason being that the eye

coordination point differs greatly on each side of the eyes, patient–to-patient and in-

between recordings.

Solutions for Problems with GUI Development

We have to no direct solution to solve this problem. The user still has to

implement the coordinate of the rectangular crop manually. Since we had 500

images on each side for each recording, we use batch processing to speed up the

cropping process which is less time-consuming.

Problems (Others)

Initially, we were given a total of 40,000 thermograms to work with, - 1

volunteer has to undergo 4 recording sessions, for 1 session, both sides of the eye

has 500 images each; We had a total of 10 volunteers. Since we only started the

semi-automated program (required manual intervention) during the second term of

PDD1, we did not have enough time to process all the 40,000 thermograms by

PDD1 review.

Solutions (Others)

To avoid this time-consuming and tedious process, we decide to utilize batch

processing techniques and implementing these algorithm to our current semi-

automated that would reduce time consumption for data collection.; Although user

will be required to manually input the coordinates before the programs starts the

processing all the 500 thermograms in one file.,

50

Page 52: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

14 - References

Brenda Witt. “Digital Infrared Thermal Imaging In Medical Therapy” Internet:

http://www.hereinmaine.com/breast-cancer/58735.php

Diane M. Szaflarski, Ph.D. “How We See: The First Steps of Human Vision”.

Internet: http://www.accessexcellence.org/AE/AEC/CC/vision_background.php [May

21, 2011].

“Dry Eye” Internet: http://www.aoa.org/x4717.xml, Retrieved [Nov. 8 , 2011].

E. D. Donnenfeld. A. Garg. D. Meyer. C. K. Mehta. J. D. Sheppard (Eds.). Clinical

Diagnosis and Management of Dry Eye and Ocular Surface Disorders (Xero-

Dacryology) .New Delhi, India: Jaypee Brothers Medical Publishers, 2006.

E Goto, Y Monden, Y Takano, A Mori, S Shimmura, J Shimazaki, and K Tsubota

“Treatment of non-inflamed obstructive meibomian gland dysfunction by an infrared

warm compression device”. Br J Ophthalmol. [Online]. 2002 December; 86(12):

1403–1407. Available: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1771385/

“EyeGiene® Insta-WarmthTM System: Features” Internet:

http://www.eyegiene.com/iwfeatures.html

“EyeGiene® Insta-WarmthTM System“ Internet:

http://www.eyegiene.com/images/PatientBrochure.pdf

“Hot Compress - A helpful alternative treatment for dry eyes” Internet:

http://www.eye-exercises-for-good-vision.com/hot-and-cold-compress-of-eyes.html

“How The Eye Works”. Internet: http://www.nkcf.org/en/about-keratoconus/how-the-

eye-works.html [May 21, 2011]

“Meibomian Gland Dysfunction” Internet: http://www.contactlens.org.nz/extra1.aspx

[Jan 16, 2012]

51

Page 53: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

“Meibomian Gland Dysfunction (MGD)” Internet:

http://www.dryeyezone.com/encyclopedia/mgd.html

Ng, E.Y.K., Ung, L.N., Ng, F.C., & Sim, L.S.J. Statistical analysis of healthy and

malignant breast thermography. J Med Eng Tech 25:253-263, 2007

N. Sarkar and B.B. Chaudhuri, "An efficient approach to estimate fractal dimension

of textural images",  presented at Pattern Recognition, 1992, pp.1035-1041.

“Overview of Dry Eye Treatment” Internet:

http://www.agingeye.net/dryeyes/overview.php#

P. Marchand. O. T. Holland. Graphics and GUIs with MATLAB Third Edition . Natick,

MA: Chapman & Hall/CRC, 2003

“Professional Resources: Value of Heat Therapy” Internet:

http://www.eyegiene.com/prodbvalueof.html

R Nave, “The Retina” Internet:

http://hyperphysics.phy-astr.gsu.edu/hbase/vision/retina.html

S. T. Smith. MATLAB Advanced GUI Development. Indianapolis,IN: Dog Ear

Publishing, 2006

Summet, Dua, R. A. Udyavara, E. Y. K. Ng. Computational Analysis of The Human

Eye with Applications. Singapore: World Scientific Publishing Co. 2011.

“Texture Analysis and its Applications” Internet:

http://www.cs.auckland.ac.nz/~georgy/research/texture/thesis-html/

node7.html#fig:visionsystem

T. M. Montgomery. “Anatomy, Physiology & Pathology of the Human Eye”. Internet:

http://www.tedmontgomery.com/the_eye/index.html

52

Page 54: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

M¨aenp¨a¨a T, Pietik¨ainen M & Ojala T “Texture classification by

multi-predicate local binary pattern operators.” Proc. 15th International

Conference on Pattern Recognition, Barcelona, Spain, 3: 951–954. (2000)

“Warm Compress Therapy For: Dry Eye: Causes of Dry Eye” Internet:

http://www.eyegiene.com/dryeyecausesof.html [Nov. 8, 2011]

“Warm Compresses” Internet:

http://www.dryeyezone.com/encyclopedia/hotcompresses.html

“Welcome to Medical Infrared” Internet: http://medicalir.com/

53

Page 55: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

APPENDICES

Page 56: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Project Planning and management

Work Schedule

S/N Work Plan/TimelineWeek 1 First consultation with supervisor

Obtaining 'Introduction to Digital Image Processing' by Alasdair McAndrew

Week 2 Research + Chap 1/2/3 (MATLAB exercises)(Understanding image processing)Week 3 Research + Chap 3/4/5 (MATLAB exercises)(Understanding image processing)

Week 4 Research + Chap 4/5/6 (MATLAB exercises)(Understanding image processing)

Week 5 Research + Chap 6/7/8 (MATLAB exercises)(Understanding image processing)

Week 6 Research + Chap 8/9 (MATLAB exercises)(Understanding image processing)

Week 7 Chap 10(MATLAB exercise) + Panel Review

Week 8 Common test break

Week 9 Term break

Week 10 Term break

Week 11 Research(tear film) + Obtaining data from National Eye centre

Week 12 Research on-Semi automated method

Running Semi-automated code with gathered data

Week 13 Running Semi-automated code with gathered dataCompiling patient's results into excel

Week 14 Research on texture analysis methodCompiling patient's results into excel

Week 15 PDD1 Final ReviewVPP Resume with Semi-Automated methodVPP VPP ReviewVPP Texture Analysis (Fractal Dimension)VPP Texture Analysis (Law’s Masking Energy)

Semester 2Week 1 Texture Analysis (Law’s Masking Energy)Week 2 Texture Analysis (Local Binary Pattern)Week 3 Texture Analysis (Local Binary Pattern)Week 4 Final Data CompilationWeek 5 Supervisor review

Week 6 - 11 GUI Development +Common Test/term breakWeek 14 Final report submission + Project Exhibitionweek 16 PDD2 Final review

Precedence list

Page 57: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

S/N Work Plan Precedence1 Research

1.1 Digital image processing(MATLAB) -1.2 Process of Semi-Automated -1.3 Process of Semi-Automated method After 1.5, 1.21.4 Process of Texture Analysis method1.5 Collection of IR images After 1.2

2 Software2.1 View captured IR eye images After 1.52.2 Image processing with obtained data After 2.12.3 Determine temperature and Average pixel value After 1.2, 1.3, 1.5, 2.1, 2.22.4 Texture Analysis After 1.2, 1.3, 1.4, 1.5, 2.1,

2.2, 2.3

Responsibility Of Assignment Matrix (RAM)

S/N Task Zul Zar Li Wei Yan1 Using MATLAB(R2007a) Primary Primary Primary2 Digital Image processing techniques Primary Primary Primary3 Running of Semi-automated method Primary Primary Secondary4 Data compilation into excel Primary Secondary Secondary5 Average pixel value + temperature Primary Primary Primary6 Mean Temperature + standard deviation Primary Primary Primary7 Research on Semi-Automated Primary Secondary Secondary8 Research on Texture Analysis Secondary Secondary Primary9 Research(general) Secondary Primary Primary

10 Gantt Chart Primary Secondary Secondary11 GUI Secondary Primary Primary

Breakdown Structure

Page 58: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

S/N Work structure Resource Duration(weeks)

1 Digital Image processing techniques Introduction to Digital Image 6-7processing by Alasdair McAndrew

2 Research on Semi-automated Method Reference slides from supervisor 13 Research on Texture Analysis Reference slides from supervisor VPP

4 Data Analysis Semi-automated codes VPP

5 Learning Texture Analysis Taught by Supervisor VPP

6 Running Semi-automated with National Eye Centre VPP

obtained data

7 Research on human eye Various websites+books 2

8 GUI Various books 4

Page 59: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Algorithm for Fractal Dimension

clc;clear all;close all; %Close all windows and clear workspace

pa=cd(‘Directory name’);

qq=dir;

dat=[];

kk=0;

for i=1:length(qq) % runs entire directory

i

if strfind(qq(i,1).name,'.jpg')

filename=(qq(i,1).name);

I1=imread(filename);

if length(size(I1))==3

I=rgb2gray(I1);

else

I=I1;

end

[m1 n1]=size(I);

if mod(m1,4)~=0

k=mod(m1,4);

p=zeros(4-k,n1);

I=[I ;p];

m1=size(I,1);

end

if mod(n1,4)~=0

l=mod(n1,4);

p=zeros(m1,4-l);

I=[I p];

end

Imax=double(I);

Imin=double(I);

Page 60: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

s=2;

[m n]=size(I);

M=max(m,n);

p=0;

while max(m,n)>2

S=((255*(s/max(m,n))));

Nr=0;

for i=2:2:m-1

sum=0;

for j=2:2:n-1

X=[(Imax(i,j)),(Imax(i,j+1)),(Imax(i+1,j)),(Imax(i+1,j+1))];

Imax(i/2,j/2)=max(X);

Y=[Imin(i,j),Imin(i,j+1),Imin(i+1,j),Imin(i+1,j+1)];

Imin(i/2,j/2)=min(Y);

sum=sum+double((((Imax(i/2,j/2))/S)-((Imin(i/2,j/2))/S)))+1;

end

Nr=Nr+sum;

end

r=s/M;

if Nr

p=p+1;

N(p)=Nr;

r1(p)=r;

D=log(Nr)/log(1/r);

end

s=s*2;

m=m/2;

n=n/2;

end

Page 61: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

plot(log(1./r1),log(N))

xlabel('log(1/r)');

ylabel('log(N)'); % plots a logarithmic graphs

X=(log(1./r1)*log(1./r1)');

X1=inv(X);

FD=X1*(log(1./r1))*(log(N)')

dat=[dat ;FD];

pa=cd(‘Directory name’ );

end

end

Algorithm for Law’s Masking Energy (LME)

function M = expertwin(ip_img, i, j, N)

sz = size(ip_img);

M = zeros(N,N);

w = (N-1)/2;

for m = -w:w

x = m + i;

if(x>0 && x<(sz(1)+1))

for n = -w:w

y = n + j;

if(y>0 && y<(sz(2)+1))

M(N-w+m,N-w+n) = ip_img(x,y);

end

end

end

Page 62: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

end

% N --> SIZE OF LAWS MASK OPERATOR

function eng_all_img = lawsanalysis(o,N)

%o = rgb2gray(o_img);

sz = size(o);

mask = lawsmask(N); % COMPUTING MASK USING FUNCTION 'LAWSMASK'.

all_filt = lawsfilter(mask); % COMPUTING ALL FILTERS FOR THE GIVEN MASK

SIZE USING FUNCTION 'LAWSFILTER'.

len = length(mask); % LENGTH, WHICH WILL BE USED AT MANY PLACES.

all_img = lawsimg(double(o),all_filt); % COMPUTING ALL IMAGES BY APPLYING

OBTAINED MASK USING FUNCTION 'LAWSIMG'.

eng_all_img = zeros(len,len); % CELL FOR STORING THE ENERGY.

for m = 1:len

for n = 1:len

new = zeros(sz);

for i=1:sz(1)

for j = 1:sz(2)

new(i,j) = (all_img{m,n}(i,j)^2);

end

end

new_sum = sum(new(:));

eng_all_img(m,n) = (new_sum);

Page 63: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

end

end

function all_filters = lawsfilter(laws_mask)

len = length(laws_mask);

all_filters = cell(len,len);

for i = 1:len

for j = 1:len

all_filters{j,i} = conv2((laws_mask(i,:)),(laws_mask(j,:))');

end

end

function all_img = lawsimg(o_img,all_filter)

sz = size(o_img);

len = length(all_filter);

all_img = cell(len,len);

for m =1:len

for n = 1:len

mask = all_filter{m,n} ;

temp = double(zeros(sz));

for i = 1:sz(1)

for j = 1:sz(2)

Page 64: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

nbr = (expertwin(o_img,i,j,len));

s = sum(mask(:));

if(s==0)

nbr_filt_mul = (mask) .* (nbr);

temp(i,j) = double(sum(nbr_filt_mul(:)));

else

nbr_filt_mul = (mask) .* (nbr);

temp(i,j) = sum(nbr_filt_mul(:))/s;

end

end

end

all_img{m,n} = temp;

end

end

function out_put = lawsmask(w_s)

L3 = [1 2 1];

E3 = [-1 0 1];

S3 = [-1 2 -1];

if(w_s==3)

Page 65: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

L3 = [1 2 1];

E3 = [-1 0 1];

S3 = [-1 2 -1];

out_put = [L3;E3;S3];

elseif(w_s==5)

L5 = conv(L3,L3);

E5 = conv(L3,E3);

S5 = conv(L3,S3);

W5 = conv(-E3,S3);

R5 = conv(S3,S3);

out_put = [L5;E5;S5;W5;R5];

elseif(w_s==7)

L7 = conv(conv(L3,L3),L3);

E7 = conv(conv(L3,L3),E3);

S7 = conv(conv(L3,L3),S3);

W7 = conv(-(conv(L3,S3)),E3);

R7 = conv(conv(-E3,S3),E3);

O7 = conv(conv(S3,S3),S3);

out_put = [L7;E7;S7;W7;R7;O7];

else

error('invalid mask size, it should be 3,5 or 7 ')

end

LME Main Algorithm

Page 66: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

clc;clear all;close all;

pa=cd('C:\Users\User\FYP\Thyroid\CEUS\CEUS Unprocessed\Benign\Benign02\

Cropped');

qq=dir;

dat=[];

kk=0;

for i=1:length(qq)

i

if strfind(qq(i,1).name,'.jpg')

filename=(qq(i,1).name);

I1=imread(filename);

if length(size(I1))==3

I=rgb2gray(I1);

else

I=I1;

end

cd('C:\Users\User\FYP\Thyroid\Group\LME')

eng_all_img = lawsanalysis(I,3)

fea=[eng_all_img(1,2) eng_all_img(1,3) eng_all_img(2,1) eng_all_img(2,2)

eng_all_img(2,3) eng_all_img(3,1) eng_all_img(3,2) eng_all_img(3,3)];

dat=[dat ;fea];

pa=cd('C:\Users\User\FYP\Thyroid\CEUS\CEUS Unprocessed\Benign\Benign02\

Cropped');

end

end

Algorithm for Local Binary Pattern (LBP)

function [finalfeaturevector]=lbp(inputimage,uniformitythreshold)

Page 67: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

warning off all

img=inputimage;

if isrgb(img)

I=rgb2gray(img);

else

I=img;

end

I1=img;

radius=[1 2 3];

noofpts=[8 16 24];

counter=1;

transcount=0;

featurevector=0;

epithelialpixel=find(I>0);

actualpixel=size(epithelialpixel,1);

[M,N]=size(I);

I(M+1,:)=zeros(1,N);

I(:,N+1)=zeros(M+1,1);

% I=padarray(I,[radius(size(radius,2)) radius(size(radius,2))],0,'both');

for i=1:size(radius,2)

transcount=0;

for j=1+radius(i):size(I,1)-radius(i)

for k=1+radius(i):size(I,2)-radius(i)

if (I(j,k)>0)

ptarray=zeros(1,noofpts(i));

%ptcount=1:noofpts(i);

%theta=2*pi*(ptcount-1)/noofpts(i)-pi/2;

for ptcount=1:noofpts(i)

theta=2*pi*(ptcount-1)/noofpts(i)-pi/2;

% disp([num2str((j+radius(i)*cos(theta))) ','

num2str((k+radius(i)*sin(theta)))]);

Page 68: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

vararray(ptcount)=I(round(j+radius(i)*cos(theta)),round(k+radius(i)*sin(theta)));

end

ptarray=sign(vararray-I(j,k));

% minarray=zeros(1,noofpts(i)-1);

% I(j,k)

% vararray

% ptarray

transition=sum(abs(diff(double(ptarray))));

transition=transition+abs(ptarray(noofpts(i))-ptarray(1));

% transition=size(findstr('01',num2str(ptarray,-

8)),2)+size(findstr('10',num2str(ptarray,-8)),2);

% transition

if transition<uniformitythreshold+1

if transition==0

img2(j,k)=2.^(noofpts(i)-1:-1:0)*double(ptarray');

else

minarray(1)=2.^(noofpts(i)-1:-1:0)*double(ptarray');

for l=2:noofpts(i)

minarray(l)=2*minarray(l-1)-(2^noofpts(i)-1)*ptarray(l-1);

% temp=dec2bin(bitshift(bin2dec(num2str(ptarray,-8)),-

1),noofpts(i));

% temp(1)=num2str(ptarray(noofpts(i)));

%minarray(l)=bin2dec(temp);

%ptarray=temp;

end

%clear ptarray transition

img2(j,k)=min(minarray);

end

else

transcount=transcount+1;

img2(j,k)=2^noofpts(i);

Page 69: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

end

img3(j,k)=std(double(vararray));

% break

else

img2(j,k)=0;

img3(j,k)=0;

end

end

% break

end

% break

finalfeaturevector(counter)=sum(sum(img3))/actualpixel;

finalfeaturevector(counter+1)=sum(sum(img2))/((2^noofpts(i))*actualpixel);

imgvar=img2(I1>0);

finalfeaturevector(counter+2)=std(imgvar)/(2^noofpts(i));

counter=counter+3;

% mean2(img3);

% mean2(img2)/2^noofpts(i);

% std2(img2)/2^noofpts(i);

% counter/(size(img,1)*size(img,2))*100;

% img2

% figure,imshow((img2)/256);

% transcount/(size(img,1)*size(img,2))*100

end

end

Main Algorithm for LBP

clc;clear all;close all

Page 70: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

pa=cd('Directory of images');

qq=dir;

dat=[];

kk=0;

%for i=1:length(qq)

for i=1:52

i

if strfind(qq(i,1).name,'.jpg')

filename=(qq(i,1).name);

I=imread(filename);

if length(size(I))==3

I1=rgb2gray(I);

else

I1=I;

end

cd('C:\Users\aru\Desktop\Group\LBP')

[F]=lbp(I1,2);

dat=[dat ;F];

pa=cd('Directory of images');

end

end

Page 71: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

MATLABMatlab, matrix labtoratory, is a high-level technical computing language and

interactive environment for algorithm development, data visulization, data analysis

and numeric computation, plotting of functions and data, implementation of

algorithms, matrix manipulations creation of user interfaces and interfacing with

programs written in other languages, including C-sharp, C plus plus, Java and

Fortran.

Although Matlab is invented primarily for numerical computing, an optional toolbox

which allows access to symbolic computing capabilities uses the MuPAD symbolic

engine.

Simulink adds graphical multi-domain simulatoin and Model-Based Design for

dynamic and embedded systems.

Matlab is widely used in all kinds of fields, engineering, science and economics.

GUI = Graphical User Interface

Figure window

Contains useful actions in its menu and toolbars – zooming in and out, rotating 3-D

axes, copying and pasting, plot edit mode, property editor, saving and exporting

(figures can be saved in binary “.fig” file format, and figures can be exported to many

different kinds of standard graphics file formats like “GIF, PNG, JPEG, TIFF, BMP,

PCX, EPS”.

Modifying object properties

- Returning a list of all object properties and their current values

*get(handle)

- Returning a list of all user-settable object properties and their current values

*set(handle)

- Returning current value of an object property

*get(handle, ‘PropertyName’)

Page 72: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

*Example:get(gcf, ‘Color’)

- Returning a list of all possible values for an object property

*Set(handle, ‘PropertyName’)

*Example: set(gca, ‘XDir’)

- Setting an object property to a new value

*set(handle, ‘PropertyName’ , ‘NewValue’)

*Example:set(gca, ‘XDir’ , ‘Reverse’)

All the above can properties can be done (not at runtime) using the Property Editor.

Creating GUI using GUIDE

-Guide is Matlab’s Graphics User Interface(GUI) design environment

-Guide stores GUI in two different files, which are generated at the first time we save

or run the GUI

* ‘.fig’ file – which contains a complete description of the GUI figure layout and the

componets of

the GUI. Changes to this file can be made in the Layout Editor.

‘.m’ file – which contains the code that controls the GUI. We can program the

callbacks in this ‘.m’ file using the M-file Editor.

Types of GUI

- Blank GUI (default)

- GUI with Uicontrols

- GUI with Axes and Menu

- Modal Question Dialog

Page 73: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

GUI (default)

GUI with Uicontrols

Page 74: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

GUI with Axes and menu

Modal Question Dialog

Page 75: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Algorithm for GUI (miscellaneous)

Load Image Button

global im;

[FileName,Pathname] = uigetfile('*.jpg', 'Load Image File');

file1 =get(handles.Loadbutton,'String');

im = imread([Pathname FileName]);

axes(handles.axes1);

imshow(im);

title('Image');

set(handles.edit3,'String',FileName);

Quit Button

function Quitbutton_Callback(hObject, eventdata, handles)

qns_ans = questdlg ('Close window ?','Closing Window','Yes','No','No')

if strcmp(qns_ans,'Yes')

Page 76: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

msgbox('Goodbye')

close(handles.figure1)

end

Fractal Button

global im;

[m1 n1]=size(im);

if mod(m1,4)~=0

k=mod(m1,4);

p=zeros(4-k,n1);

im=[im ;p];

m1=size(I,1);

end

if mod(n1,4)~=0

l=mod(n1,4);

p=zeros(m1,4-l);

im=[im p];

end

Imax=double(im);

Imin=double(im);

s=2;

[m n]=size(im);

M=max(m,n);

p=0;

while max(m,n)>2

S=((255*(s/max(m,n))));

Nr=0;

for i=2:2:m-1

sum=0;

for j=2:2:n-1

Page 77: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

X=[(Imax(i,j)),(Imax(i,j+1)),(Imax(i+1,j)),(Imax(i+1,j+1))];

Imax(i/2,j/2)=max(X);

Y=[Imin(i,j),Imin(i,j+1),Imin(i+1,j),Imin(i+1,j+1)];

Imin(i/2,j/2)=min(Y);

sum=sum+double((((Imax(i/2,j/2))/S)-((Imin(i/2,j/2))/S)))+1;

end

Nr=Nr+sum;

end

r=s/M;

if Nr

p=p+1;

N(p)=Nr;

r1(p)=r;

D=log(Nr)/log(1/r);

end

s=s*2;

m=m/2;

n=n/2;

end

axes(handles.axes7);

plot(log(1./r1),log(N))

xlabel('log(1/r)');

ylabel('log(N)');

X=(log(1./r1)*log(1./r1)');

X1=inv(X);

FD=X1*(log(1./r1))*(log(N)');

Res = FD;

set(handles.Fractaltext,'String',Res);

Page 78: Effect of Heat Treatment on Eye using Thermogram: A Comprehensive Analysis

Reset Button

function Reset_Callback(hObject, eventdata, handles)

cla(handles.axes7,'reset');

cla(handles.axes1, 'reset');

set(handles.edit3,'String','');

set(handles.Averagetext,'String','');

set(handles.Fractaltext,'String','');