Anda di halaman 1dari 81

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

SUPERVISOR
ACHARYA RAJENDRA UDYAVARA

Title Page:

Project title:

Team Members:

Effect of Heat Treatment on Eye using Thermogram:


A Comprehensive Analysis

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)

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

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 4950
14 - References.........................................................................................Page 51-53

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

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.

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, Volunteers 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.

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.

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
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:

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.

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

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 ones 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 isnt
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

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

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 doesnt 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

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

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

7 - System Block Diagram


u
q
g
S
f
IR
(
)
D
a
c
x
E
m
h
w
r
n
s
o
it
v
e
d
lA
p
P
y
T
b
k
j'C

Proposed Project Flow Chart

16

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

SemiAutomate
d Method

Statistical
Texture
Analysis

Statistical
Analysis

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), Laws Masking Energy (LME) and Local Binary
3.

Pattern (LBP)
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

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

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

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);
qw=~qw1;

% Define the region of interest (ROI)

% Complement of ROI

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

Circular region of interest created

20

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

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

%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 subpattern 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

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 objects 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 )
1
log( )
r

24

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

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 Laws 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

27

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

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

Average temperature (with standard deviation)


Recordin
g

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

Table 1a

Results(Semi-automated)
34.4
34.2
34
33.8
Temperature

33.6
33.4
33.2
33
32.8

1st

2nd

Table 1b

30

3rd

4th

9.1.2 - Results with Automated method


Automated 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

Results (Fractal Dimension)


1.95
1.94
1.93

Axis Title

1.92
1.91
1.9
1.89

1st Recording

2nd Recording

Table 2b

3rd Recording

4th Recording

32
9.1.2.2 - Results with LME

LME 1
700000000
600000000
500000000
400000000
300000000
200000000
100000000
0

1st

2nd

3rd

4th

3rd

4th

Table 3a

LME 2
600000000
580000000
560000000
540000000
520000000
500000000
480000000
460000000
440000000

1st

2nd

Table 3b

33

LME 3
1000000000
980000000
960000000
940000000
920000000
900000000
880000000
860000000
840000000
820000000

1st

2nd

Table 3c

3rd

4th

LME 4
30000000
25000000
20000000
15000000
10000000
5000000
0

1st

2nd

3rd

4th

Table 3d

34

LME 5
45000000
40000000
35000000
30000000
25000000
20000000
15000000
10000000
5000000
0

1st

2nd

Table 3e

3rd

4th

LME 6
1000000000
980000000
960000000
940000000
920000000
900000000
880000000
860000000
840000000

1st

2nd

3rd

4th

Table 3f

35

LME 7
45000000
40000000
35000000
30000000
25000000
20000000
15000000
10000000
5000000
0

1st

2nd

Table 3g

3rd

4th

LME 8
120000000
100000000
80000000
60000000
40000000
20000000
0

1st

2nd

Table 3h

36

3rd

4th

LME (Combined Results)


1200000000

1000000000

800000000

600000000

400000000

200000000

Table 3i

37

9.1.2.3 - Results with LBP

LBP 1
3.5
3
2.5
2
Axis Title

1.5
1
0.5
0

1st

1st

1st

1st

3rd

4th

Table 4a

LBP 2
0.06
0.06
0.06
0.05
Axis Title

0.05
0.05
0.05
0.05

1st

2nd

Table 4b

38

LBP 3
0.22
0.21
0.21
Axis Title
0.2
0.2
0.19

1st

2nd

3rd

4th

3rd

4th

Table 4c

LBP 4
5
4.5
4
3.5
3
Axis Title 2.5
2
1.5
1
0.5
0

1st

2nd

Table 4d

39

LBP 5
0.12
0.12
0.12
0.12
0.12
Axis Title 0.11
0.11
0.11
0.11
0.11
0.1

1st

2nd

3rd

4th

3rd

4th

Table 4e

LBP 6
0.33
0.33
0.32
Axis Title
0.32
0.31
0.31

1st

2nd

Table 4f

40

LBP 7
7
6
5
4
Axis Title

3
2
1
0

1st

2nd

3rd

4th

Table 4g

LBP 8
0.16
0.16
0.16
0.15
0.15
Axis Title

0.15
0.15
0.15
0.14
0.14

1st

2nd

Table 4h

3rd

4th

41

LBP 9
0.37
0.36
0.36
0.36
0.36
Axis Title

0.36
0.35
0.35
0.35
0.35

1st

2nd

Table 4i

3rd

4th

Results (LBP Combined Results)


7
6
5
4
Axis Title
3
2
1
0

Table 4j

42
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

Results (w/o eye mask)


34
33.8
33.6
33.4
Temperature

33.2
33
32.8
32.6

1st

2nd

4th

43

10 - GUI Development
A 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.


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
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;
m=0;

% Pixel count

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

Reset Clear all axes and texts

Quit Terminates the program.

4611- 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. 3 rd
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

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

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/doesnt work. Thus, some function will cause MATLAB errors.
The second problem was that the accuracy of the results as the Semiautomated 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

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, patientto-patient and inbetween 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 semiautomated 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

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 (XeroDacryology) .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):
14031407. 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-theeye-works.html [May 21, 2011]
Meibomian Gland Dysfunction Internet: http://www.contactlens.org.nz/extra1.aspx
[Jan 16, 2012]

51

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.phyastr.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/thesishtml/node7.html#fig:visionsystem

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


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

52

Maenpaa T, Pietikainen M & Ojala T Texture classification by


multi-predicate local binary pattern operators. Proc. 15th International
Conference on Pattern Recognition, Barcelona, Spain, 3: 951954. (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

APPENDICES

Project Planning and management


Work Schedule
S/N

Work Plan/Timeline

Week 1

First consultation with supervisor


Obtaining 'Introduction to Digital Image Processing' by Alasdair
McAndrew
Research + Chap 1/2/3 (MATLAB exercises)(Understanding image
processing)
Research + Chap 3/4/5 (MATLAB exercises)(Understanding image
processing)
Research + Chap 4/5/6 (MATLAB exercises)(Understanding image
processing)
Research + Chap 6/7/8 (MATLAB exercises)(Understanding image
processing)
Research + Chap 8/9 (MATLAB exercises)(Understanding image
processing)
Chap 10(MATLAB exercise) + Panel Review
Common test break

Week 2
Week 3
Week 4
Week 5
Week 6
Week 7
Week 8
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
Week 14
Week 15
VPP
VPP
VPP
VPP
Semester 2
Week 1
Week 2
Week 3
Week 4
Week 5
Week 6 - 11
Week 14
week 16

Running Semi-automated code with gathered data


Compiling patient's results into excel
Research on texture analysis method
Compiling patient's results into excel
PDD1 Final Review
Resume with Semi-Automated method
VPP Review
Texture Analysis (Fractal Dimension)
Texture Analysis (Laws Masking Energy)
Texture Analysis (Laws Masking Energy)
Texture Analysis (Local Binary Pattern)
Texture Analysis (Local Binary Pattern)
Final Data Compilation
Supervisor review
GUI Development +Common Test/term break
Final report submission + Project Exhibition
PDD2 Final review

Precedence list
S/N
1
1.1
1.2
1.3
1.4
1.5

Work Plan

Precedence

Research
Digital image processing(MATLAB)
Process of Semi-Automated
Process of Semi-Automated method
Process of Texture Analysis method
Collection of IR images

After 1.5, 1.2


After 1.2

2.3

Software
View captured IR eye images
Image processing with obtained data
Determine temperature and Average
pixel value

2.4

Texture Analysis

2.1
2.2

After 1.5
After 2.1
After 1.2, 1.3, 1.5, 2.1,
2.2
After 1.2, 1.3, 1.4, 1.5,
2.1,
2.2, 2.3

Responsibility Of Assignment Matrix (RAM)


S/N
1
2
3
4
5
6
7
8
9
10
11

Task

Zul
Primary
Primary

Zar Li
Primary
Primary

Primary

Primary

Data compilation into excel


Average pixel value + temperature
Mean Temperature + standard deviation

Primary
Primary
Primary

Secondary
Primary
Primary

Research on Semi-Automated
Research on Texture Analysis
Research(general)

Primary
Secondary
Secondary

Secondary
Secondary
Primary

Gantt Chart
GUI

Primary
Secondary

Secondary
Primary

Using MATLAB(R2007a)
Digital Image processing techniques
Running of Semi-automated method

Wei Yan
Primary
Primary
Seconda
ry
Seconda
ry
Primary
Primary
Seconda
ry
Primary
Primary
Seconda
ry
Primary

Breakdown Structure
S/N

Duration(weeks)

Research on Texture Analysis

Resource
Introduction to Digital
Image
processing by Alasdair
McAndrew
Reference slides from
supervisor
Reference slides from
supervisor

Data Analysis

Semi-automated codes

VPP

Learning Texture Analysis

Taught by Supervisor

VPP

Running Semi-automated with

National Eye Centre

VPP

1
2

Work structure
Digital Image processing
techniques
Research on Semi-automated
Method

6-7

1
VPP

obtained data
7

Research on human eye

Various websites+books

GUI

Various books

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

% runs entire directory

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

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 Laws 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

end

% N --> SIZE OF LAWS MASK OPERATOR


function eng_all_img = lawsanalysis(o,N)
%o = rgb2gray(o_img);
sz = size(o);
mask = lawsmask(N);
all_filt = lawsfilter(mask);

% COMPUTING MASK USING FUNCTION 'LAWSMASK'.


% 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);
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)

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)

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


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)
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)))]);
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)),-

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

1),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);
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
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

MATLAB
Matlab, 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)

*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 Matlabs 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

GUI (default)

GUI with Uicontrols

GUI with Axes and menu

Modal Question Dialog

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

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

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','');

Anda mungkin juga menyukai