You are on page 1of 34

SOME MATHEMATICAL

TOPICS FOR IMAGE


PROCESSING APPLICATIONS

Dr. P. Sudhakara Rao


Prof. ECE
Mathematics for Quality Sorting
Fruits and Vegetables
Inspection for quality is an important procedure for
marketing, storing and processing of fruits and
Vegetables. Size, shape, colour and defects are
some of the significant properties related to the
quality of fruits.

Application of machine vision for quality inspection


of fruits and Vegetables can solve many of the
limitations related to the manual inspection.

The machine vision inspection system essentially


involves three main processes namely image
acquisition, image processing and decision making.
Mathematics for Quality Sorting
Fruits and Vegetables
Acquisition of Multiple images of Fruit or
Vegetable
Carryout Image analysis on-
on-line
The quality parameters may include size, shape,
colour, bruises, etc.
Choose the best mathematical solution for
sorting them baed on the quality parameters
measurement/ evaluation and assign grade
number for each fruit
The mechanical separator unit directs the fruits
in to different bins based on the grade number.
Online Apple Sorting Machine
Online Apple Sorting Machine
Imaging Section
FRUITS & VEGETABLE SORTING
SORTING CRITERIA FOR TODAY’S
DISCUSSION
SIZE SORTING
SHAPE SORTING
COLOUR SORTING
Size Evaluation Methods
METHODS

ANALYTICAL STATISTICAL

SYMMETRY ABSOLUTE MEASURE

CIRCLE RADIUS AND AREA


SIGNATURE
PARABOLA
ELLIPSE RELATIVE MEASURE

COEFFICIENT OF
ASYMMETRY
VARIATION
PRINCIPAL AXIS
Object Tilt calculation
{ (x i , y i ), i = 1 , 2 , 3 ,... n }

φ = (1 2 ) tan −1
[ 2I xy (I x − I y )]
n 2 n 2

Ix = ∑ (x
i =1
i − x av ) , Iy = ∑ (y
i =1
i − y av ) and

I
xy
=
n

i=1
(x i − x av ) ( y
i
− y
av
)
x av = ∑x i n , y av = ∑ yi n
I
x = moment of inertia about x − axis
I
y = moment of inertia about y − axis
n 2 n 2

Ix = ∑ (x
i =1
i − x av ) , Iy = ∑ (y
i =1
i − y av ) and

{ ( x i , yi ), i = 1,2,3,...n}
ANALYTICAL- SYMMETRY
CIRCLE Method
x 2 + y 2 + 2 gx + 2 fy + c = 0
Using the Cramer’s rule g = (∆1 / ∆), f = (∆2 / ∆)
x1 y1 1
∆ = 4 x2 y2 1 c = (∆3 / ∆)
x3 y3 1
(x 1
2
+ y 12 ) y1 1 (
Pc = − g , − f )
(
∆1 = − 2 x + y2
2
2 2
) y2 1
(
x + y3
3
2
2
) y3 1
x1
∆ 2 = − 2 x2
(x
(x 2
1
2

2
+ y 12
+ y2
2
)
)
1
1 r = (g 2 + f
2
− c )
x3 (x 3
2
+ y3
2
) 1
x1 y1 (x 1
2
+ y12 )
∆ 3 = − 4 x2 y2 (x 2
2
+ y2
2
)
x3 y3 (x 3
2
+ y3
2
)
ANALYTICAL- SYMMETRY
PARABOLA Method
y = ax 2 + bx + c
a, b and c are obtained by the principle of Least Squares by
minimizing the residual or error sum of squares (E) given as,

∑ [y − (ax )]
2 2
E = + bx + c
∂E ∂a = 0, ∂E ∂b = 0 and ∂E ∂c = 0
∑y i = a ∑ xi + b∑ xi + c
2

∑x yi = a ∑ xi + b∑ xi + c ∑ xi
3 2
i

∑x yi = a ∑ xi + b∑ xi + c ∑ xi
2 4 3 2
i

The above are solved for a, b and c, Then


X 2 = 4 AY Latus Re ctum = 4 A
The length of Latus rectum is determined to be 40 for this
image using MATLAB
Analytical- Symmetry
Ellipse Methods
2a = [ (x
mid 2 − xmid1 ) + ( ymid 2 − ymid1 )
2 2
]
2b = [ (x max − x min )2 + ( y cor 2 − y cor 1 )
2
]
e = [ (a 2
− b 2
) a 2
] eccentricity of the ellipse
Analytical- Asymmetry
Principal Axis Methods
h= [ (x stem − x calyx ) + (y
2
stem − y calyx )]
2

H = h [Minimum ( A1, A2 ) Maximum( A1, A2)]

∫∫
x , y∈object
x dx dy 1 ∫
2 x , y∈boundary
(
xydx − 1
2
2
x dy )
xc = =
∫∫
x , y∈object
dx dy 1 ∫
2 x , y∈boundary
( ydx − xdy )
n
∑ y x
k =0
[( 2 2
k k − x k −1 − x k
2
)
y k − y k −1 ( )]
=
n
[ ( )
2 ∑ y k x k − x k −1 − x k y k − y k −1
k =0
( )]
Analytical- Asymmetry
Principal Axis Methods
∫∫
x , y∈object
y dx dy 1 ∫
2 x , y∈boundary
( 1
2
2
y dx − xydy )
yc = =
∫∫
x , y∈object
dx dy 1 ∫
2 x , y∈boundary
( ydx − xdy )
n

k=0
[ yk
2
(x k − x k −1 )− xk (yk
2
− y k −1
2
)]
=
n
2 ∑
k=0
[y k ( x k − x k −1 )− xk (y k − y k −1 )]

x k − xc xk −1 − xc
∆Ak = 0. 5
y k − yc y k −1 − yc

n xk − xc xk −1 − xc
A = 0. 5 ∑
k =0 y k − yc yk −1 − yc
Analytical- Statistical
RADIUS AND AREA SIGNATURE
METHOD
Contour of
“Green Apple”

[
Rk = (x k − xc ) + ( y k − y c )
2
]
2 1/ 2

xk − xc x k −1 − xc
∆ Ak = 0. 5
yk − yc y k −1 − y c

The area below the


curves is
determined and
used for comparing
Contour of the sizes of different
“Red-Yellow” apples
FRUITS SHAPE MEASUREMENT
Shape is a feature easily comprehended by humans but
difficult to quantify or define by the computer.
Most existing computer algorithms are developed for
industrial objects having more definite shape.
Agricultural products like fruits have variable shapes.
Their natural variability and diversity create difficult and
practical problems in determining the shape.
The shape requirements are somewhat abstract and
difficult to comprehend since there are no standard
shapes of fruits available for comparison.
Usually the shape of a fruit is determined by judging
how well it conforms to the characteristic shape of the
fruit variety.
Generally four shape categories are used namely, well
formed, fairly well formed, slightly deformed and
seriously deformed.
Fruits SHAPE measurement

RADIUS SIGNATURE METHOD


Fruits SHAPE measurement

RADIUS SIGNATURE METHOD


SIX RADII AND THEIR MEDIAN SIGNATURES APPLE-1
Pos ture-1 Pos ture-2 Pos ture-3 Pos ture-4
Pos ture-5 Pos ture-6 Median
1.2

1.15
DU S

1.1
EDA
R I

1.05
A
MIS
L

1
O
NR

0.95

0.9

0.85
0 50 100 150 200 250
BOUNDARY POINTS

Radius signatures for Apple-1 and their median signature

Radius signatures for Apple-2 and their median signature


Fruits SHAPE measurement

AREA SIGNATURE METHOD


SIX AREAS AND THEIR M EDIAN SIGNATURES APPLE-1
POSTURE-1 POSTURE-2 POSTURE-3 POSTURE-4
POSTURE-5 POSTURE-6 M EDIAN

1.45
EA

1.35
AR

1.25
E
ISD

1.15
A
ML

1.05
O
NR

0.95

0.85

0.75
0 50 100 150 200 250
BOUNADARY SEGM ENTS

Area signatures for Apple-1 and their median

SIX AREAS AND THEIR M EDIAN SIGNATURES APPLE-2

POSTURE-1 POSTURE-2 POSTURE-3 POSTURE-4


POSTURE-5 POSTURE-6 M EDIAN
1.5
1.4
E
RA

1.3
DA

1.2
L E
IS

1.1
A
M

1
O
NR

0.9
0.8
0.7
0 50 100 150 200 250
BOUNDARY SEGM ENTS

Area signatures for Apple-2 and their median


Fruits SHAPE measurement

CONTOUR VECTOR METHOD

∆rk+1
(xk+1,yk+1)

rk + 1 rk
(xk,yk)

(xk-1,yk-1)
rk −1
∆rk
(xc,yc)
∆θk

Sectoral radius vectors


Fruits SHAPE measurement

CONTOUR VECTOR METHOD


→ → →

∆ rk = rk − rk −1 ,
(xk+1,yk+1)
→ → →
∆rk+1
∆ rk + 1 = rk + 1 − rk , k = 0 ,1, 2 ,......... n
→ → → rk +1 (xk,yk)
rk
where rk = (x k − xc ) i + (yk − yc ) j
→ → → (xk-1,yk-1)
rk −1 = (x k −1 − x c ) i + ( y k −1 − y c ) j and
rk −1
→ → →
(xc,yc) ∆rk
∆ rk = (x k − x k − 1 ) i + ( y k − y k −1 ) j
→ → →
θk
∆ rk + 1 = (x k +1 − x k ) i + ( y k +1 − y k ) j
 → →

 
−1 ∆ rk • ∆ rk +1 → →→
∆θk = cos  → →  ∆ rk = rk − r k −1
 ∆r ∆r 
 k k +1  = [ (x −x
k k−1) 2
+ ( yk − yk−1 ]
) 2
Fruits SHAPE measurement

CONTOUR VECTOR METHOD


CONTOUR VECTORS MEDIAN PLOT
APPLE-1
1.1

∆θk 1.05
IN
RAD
1
IAN
S
0.95

0.9

0.85

0.8
0 20 40 60 80 100 120 140 160 180 200 220 240
SAMPLE POINTS

Contour vectors median plot for six postures of Apple-1


Fruits SHAPE measurement

DATA ANALYSIS
CORRELATION TECHNIQUE

r(x, y) =Cov (x, y) (σx ×σy )


1
where, Cov(x, y ) =
N
∑ (xi − xav )( yi − y av )

σ x = (1 N )∑(xi − xav )2 and σ y = (1 N )∑ ( yi − yav )2

P.E. = 0.6745 1 − r2( ) ( N)


ρ = r ± P.E.
Fruits SHAPE measurement

DATA ANALYSIS
FFT TECHNIQUE
N
F (u ) = (1 N ) ∑ r (k ) exp [− j 2π u k N ], u = 0 ,1, 2 ,........ N
K =1

S = ∑ F (h ) ∗ h m , m = 1,2 or 3.......... S − Shape Number


FREQUENCY DISTRIBUTION AREA M EDIAN OF APPLE-1 &
APPLE-2 Apple-1 Apple-2
7

5
(0)

4
F(h)/F

0
1 2 3 4 5 6 7 8 9
h

Frequency distribution of median area signatures of Apple-1


and Apple-2
LINEAR DISCRIMINANT
ANALYSIS FOR IMAGE
PROCESSING
LDA FOR signal & Image
PROCESSING
Classification and
Dimensionality Reduction

LDA PCA

Does data classification; classification in speech Does more of feature


recognition classification
Doesn’t change the location, only draw a decision
region between the given classes
Maximizes the ratio of between-class variance to Changes the shape
the within-class variance and location of the
Within-class frequencies are unequal and original data sets
guaranteeing maximal separability when transformed to a
different space
Data sets and test vectors in
original – An Example
DIFFERENT APPROACHES TO
LDA
Data sets can be transformed and test vectors can be
classified in the transformed space by two different
approaches.

Class-dependent transformation: The main objective is to


maximize class variance to within class variance ratio so
that adequate class separability is obtained. The class-specific
type approach involves using two optimizing criteria for
transforming the data sets independently.

Class-independent transformation: This approach involves


maximizing the ratio of overall variance to within class variance.
This approach uses only one optimizing criterion to transform
the data sets and hence all data points irrespective of their class
identity are transformed using this transform.
LDA
MATHEMATICAL OPERATION
Formulate the data sets and the test sets,
which are to be classified in the original
space.
Compute the mean of each data set, µ1 for
set1 and µ2 for set 2, and mean of entire
data set, µ3 .
µ3 = p1*µ1 + p2*µ2
p1 & p2 are the apriori probabilities of
the classes and in the present case of
two class problem, the probability
factor is assumed to be 0.5.
Within-class and between-class scatter
are used to formulate criteria for class
separability. Within-class scatter is the
covariance of the classes.
Covariance matrix is then computed
The between-class scatter is computed
LDA
MATHEMATICAL OPERATION
Sbcan be thought of as the covariance of data set whose
members are the mean vectors of each class.
The optimizing criterion in LDA is the ratio of between-
class scatter to the within-class scatter.
The solution obtained by maximizing this criterion
defines the axes of the transformed space.
It should be noted that if the LDA is a class dependent
type
For the class independent transform
LDA
MATHEMATICAL OPERATION
An eigen vector of a transformation
represents a 1-D invariant subspace of
the vector space in which the
transformation is applied.

eigen vector direction in


class dependent type

For the class independent LDA,

eigen vector direction in


class independent type
LDA
MATHEMATICAL OPERATION
Once the transformations are completed using the LDA
transforms, Euclidean distance or RMS distance is used to
classify data points. Euclidean distance is computed using

dist _ n = (transform _ n _ spec ) X x − µ ntrans


T
LDA
MATHEMATICAL OPERATION
Data sets in original space and transformed space along with the
tranformation axis for class dependent LDA of a 2-class problem
HIS COLOUR SPACE
HSI is modelled with cylindrical
coordinates
Hue (H) is represented as an angle,
varying from 0o to 360o.
Saturation (S) corresponds to the
radius, varying from 0 to 1.
Intensity (I) varies along the (z) axis
with 0 being black and 1 being
white.
Hue is a colour attribute that
describes a pure colour
255  0  (2 R − G − B )  
H=
360 
90 + tan −1  ( 1800 if G < B )


 3 (G − B )  
Double cone model of HSI colour space
Apple Colour Classification Using
LDA

You might also like