TITLE SLIDE

“ I nt r oduct i on t o MATLAB and i t s Comput at i onal
Power s i n I mage Pr ocessi ng”
By :-
“b l ue i nk i nf ot ec h p vt . l t d . ”
www.blueink.in
Join us at facebook:-
“blueink infot ech”
COM PANY INTRODUCTION
• b l ue i nk i nf ot ec h p vt . l t d . has st ar t ed i t s
j our ney i n ear l y 2008. Bl ue Ink i s an i ncubat ee
company of Technol ogy Busi ness Incubat or,
KIET.
• Company’s w or k domai ns ar e sof t war e
devel opment , w eb devel opment , pr oj ect
devel opment and t rai ni ng, e-l ear ni ng and
cont ent management , Embedded Syst ems.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Out l i ne
• Par t I: Int r oduct i on and Over vi ew (Case St udy)
• Par t II: M ATLAB Deskt op
• Par t III: Types of Fi l es
• Par t IV: M at r i x M ani pul at i ons, Common
Funct i ons, Pl ot s i n M ATLAB
• Par t V: Image Pr ocessi ng Commands
• Par t VI: M odel Demonst rat i on
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
What i s M ATLAB?
• M ATLAB® (M ATr i x LABorat or y) i s a hi gh-per f or mance l anguage f or
t echni cal comput i ng. It i s an i nt eract i ve syst em w hose basi c dat a
el ement i s an ar ray t hat does not require dimensioning. Al l ows t o
sol ve many t echni cal comput i ng pr obl ems, exampl es of w hi ch
i ncl ude:
– M at r i x mani pul at i on
– Fi ndi ng t he r oot s of pol ynomi al s
– Di gi t al si gnal pr ocessi ng appl i cat i ons (t ool box)
– Pl ot t i ng: x-y and pol ar, 3D graphi cs
Par t i cul ar l y hel pf ul f or :
– Al gor i t hm devel opment ,
– M odel i ng, si mul at i on, and pr ot ot ypi ng,
– Dat a acqui si t i on
– Dat a anal ysi s, expl orat i on, and vi sual i zat i on,
– Appl i cat i on devel opment , i ncl udi ng graphi cal user i nt er f ace bui l di ng.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Level s of Image Pr ocessi ng
• Ther e ar e no cl ear -cut boundar i es i n t he
cont i nuum f r om i mage pr ocessi ng at one end
t o comput er vi si on at t he ot her. However, a
usef ul paradi gm i s t o consi der t hee t ypes of
comput er i zed pr ocesses:
• Low level processes
• M id level processes
• High level processes
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Low l evel pr ocesses
• A l ow l evel processes i nvol ve pr i mi t i ve operat i ons, such as
i mage pr eprocessi ng t o r educe noi se, cont rast
enhancement , and i mage shar peni ng. A l ow-l evel process i s
charact er i zed by t he f act t hat bot h i t s i nput s and out put s
t ypi cal l y ar e i mages.
• M i d-l evel processes on i mages i nvol ve t asks such as
segment at i on (par t i t i oni ng an i mage i nt o r egi ons or
obj ect s), descr i pt i on of t hose obj ect s t o r educe t hem t o a
f or m sui t abl e f or comput er processi ng, and cl assi f i cat i on
(r ecogni t i on) of i ndi vi dual obj ect s. A mi d-l evel process i s
charact er i zed by t he f act t hat i t s i nput s general l y ar e
i mages, but i t s out put s ar e at t r i but es ext ract ed f rom t hose
i mages (e.g. edges, cont ours, and t he i dent i t y of i ndi vi dual
obj ect s).
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Hi gh Level Pr ocesses
• Hi gh l evel pr ocessi ng i nvol ves “ maki ng sense”
of an ensembl e of r ecogni zed obj ect s, as i n
i mage anal ysi s, and, at f ar end of cont i nuum,
per f or mi ng t he cogni t i ve f unct i ons nor mal l y
associ at ed w i t h human vi si on.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Appl i cat i ons of Image Pr ocessi ng
• Weat her f or cast i ng
• M achi ne vi si on measur i ng di st ance of obj ect s
• Obj ect det ect i on
• Fi ndi ng an odd pr oduct on t he conveyor bel t
• VIDEO DEM O
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
M ATLAB Syst em
• M ATLAB syst em consi st s of f i ve mai n par t s
– Devel opment Envi r onment
• Set of t ool s and f aci l i t i es t hat hel p you use M ATLAB f unct i ons and
f i l es.
– M ATLAB M at hemat i cal Funct i on Li br ar y
• Col l ect i on of f unct i ons l i ke sum, si ne, cosi ne, and compl ex
ar i t hmet i c, mat r i x i nver se, mat r i x ei genval ues, and f ast Four i er
t ransf or ms.
– The M ATLAB Language
• Hi gh-l evel mat r i x/ ar ray l anguage wi t h cont r ol f l ow st at ement s,
f unct i ons, dat a st r uct ur es, i nput / out put , and obj ect -or i ent ed
pr ogrammi ng f eat ur es.
– Gr aphi cs
• Pr ovi des ext ensi ve f aci l i t i es f or di spl ayi ng vect or s and mat r i ces as
graphs, as wel l as annot at i ng and pr i nt i ng t hese graphs.
– Appl i cat i on Pr ogr am Int er f ace (API)
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
M ATLAB Deskt op
When you st ar t M ATLAB, M ATLAB deskt op appears,
cont ai ni ng t ool s (graphi cal user i nt er f aces) f or managi ng
f i l es, var i abl es, and appl i cat i ons associ at ed w i t h M ATLAB.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Hel p i n M ATLAB
• >> hel p <f unct i onname>
Shows hel p document f or a gi ven f unct i on
Exampl e: help mean
• >> l ookf or <keywor d>
Sear ches al l t he hel p document s f or a gi ven
keywor d
Exampl e: lookfor average
• >> demo
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Types of Fi l es
• .m f i l e - command w i ndow i s used t o execut e
si ngl e command. But i f i t i s r equi r ed t o
execut e/ save a pr ogram, we need t o generat e
a mat l ab pr ogrammi ng f i l e w hi ch i s saved as
xyz.m (mat f i l e)
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
SIM ULINK
• Si mul i nk
®
sof t war e model s, si mul at es, and anal yzes
dynami c syst ems. It enabl es you t o pose a quest i on about a
syst em, model t he syst em, and see what happens.
• Wi t h Si mul i nk, you can easi l y bui l d model s f rom scrat ch, or
modi f y exi st i ng model s t o meet your needs. Si mul i nk
suppor t s l i near and nonl i near syst ems, model ed i n
cont i nuous t i me, sampl ed t i me, or a hybr i d of t he t wo.
Syst ems can al so be mul t i rat e — havi ng di f f er ent par t s t hat
ar e sampl ed or updat ed at di f f er ent rat es.
• Thousands of sci ent i st s and engi neers around t he wor l d use
Si mul i nk t o model and sol ve r eal probl ems i n a var i et y of
i ndust r i es, i ncl udi ng:
• Aerospace and Def ense
• Aut omot i ve
• Communi cat i ons
• El ect roni cs and Si gnal Processi ng
• M edi cal Inst r ument at i on
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Var i abl es: Scal ar s, Vect or s and
M at r i ces
Real Scalars
>> x = 5
x = 5
Complex Scalars
>> x = 5+10j %5+10i wor ks, as does 5+10* j
x =
5.0000 +10.0000i
Row Vect or (1 x 3)
>> x = [ 1 2 3 ]
x =
1 2 3
Column Vect or ( 3 x 1)
>> x = [ 1 ; 2 ; 3 ] ; %” ; ” supresses out put
>> x
x =
1
2
3
M at rix (3 x 3)
>> x = [ 1 2 3 ; 4 5 6 ; 7 8 9 ]
x =
1 2 3
4 5 6
7 8 9
Not e: Variable Names are case sensit ive
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Gener at i ng Vect or s and t he Col on Oper at or
>> x = [ 0 : 0.2 : 1 ] % 0 t o 1 i n i ncr ement s of 0.2
x =
0 0.20 0.40 0.60 0.80 1.00
>> x = l i nspace(0, 1, 6) % 6 poi nt s f r om 0 t o 1 on a l i near scal e
x =
0 0.20 0.40 0.60 0.80 1.00
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Generat i ng M at r i ces
>> B = [ 1 2 ; 8 9 ]
ans =
1 2
8 9
>> ones( 2,2) % generat es an all ones 2 x 2 mat rix
ans =
1 1
1 1
>> zeros( 2,3) % generat es an all zero 2 x 3 mat rix
ans =
0 0 0
0 0 0
>> rand( 3,3) % generat es a random 3 x 3 mat rix
ans =
0.4447 0.9218 0.4057
0.6154 0.7382 0.9355
0.7919 0.1763 0.9169
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Accessi ng M at r i x El ement s
>> A= [ 1 2 3 ; 4 5 6 ; 7 8 9] ;
>> x = A ( 1, 3 ) %A(<row >,<column>)
x =
3
A =
1 2 3
4 5 6
7 8 9
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Compl ex Number Operat i ons
>> x = 3+4j
>> abs(x) %Absol ut e val ue.
x = 5
>> angl e(x) %Phase angl e (i n r adi ans).
x = 0.9273
>> conj (x) %Compl ex conj ugat e.
x = 3-4j
>> i mag(x) %Compl ex i magi nar y par t .
x = 4
>> r eal (x) %Compl ex r eal par t .
x = 3
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Some Usef ul Funct i ons
Some usef ul mat h f unct i ons:
si n(x), cos(x), t an(x), at an(x), exp(x), l og(x), l og10(x), sqr t (x)
>> t = [ 0 : 0.01 : 10 ] ;
>> x = si n ( 2 * pi * t );
Some usef ul mat r i x and vect or f unct i ons:
>> si ze (A)
ans =
3 3
>> l engt h ( t )
ans =
1001
A =
1 2 3
4 5 6
7 8 9
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
What i s sum(A' )' ?
A =
1 2 3
4 5 6
7 8 9
M or e Operat or s and Funct i ons
For vect ors, SUM ( X) is t he sum of t he element s of X. For mat rices, SUM ( X) is a row vect or w it h
t he sum over each column.
>> sum ( A )
ans =
12 15 18
>> sum ( ans ) % equivalent t o sum( sum( A) )
ans =
45
>> A’ % equivalent t o t ranspose( A)
ans =
1 4 7
2 5 8
3 6 9
>> diag( A)
ans =
1
5
9
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Root s of Pol ynomi al s
• Fi nd t he r oot s of t he pol ynomi al : 13 x
3
+ 25 x
2
+ 3 x + 4
>> C = [ 13 25 3 4] ;
>> r = r oot s(C)
r =
-1.8872
-0.0179 + 0.4034i
-0.0179 - 0.4034i
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
>> x = [ 0 : 0.001 : 2* pi ] ;
>> y = si n ( x );
>> pl ot (x,y) ;
Cont i nuous Ti me Pl ot s
0 1 2 3 4 5 6 7
-1
-0.5
0
0.5
1
• The pl ot f unct i on has di f f er ent f or ms, dependi ng on t he i nput ar gument s.
If y i s a vect or, pl ot (y) pr oduces a pi ecewi se l i near graph of t he el ement s
of y ver sus t he i ndex i t s el ement s. If you speci f y t wo vect or s as ar gument s,
pl ot (x,y) pr oduces a graph of y ver sus x.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Di scr et e Ti me Pl ot s – St ems
• St em f unct i on i s ver y si mi l ar t o pl ot . It i s used t o pl ot di scr et e t i me
sequences. For mor e i nf o: hel p st em
• Exampl e:
>> k = [ 0 : 30 ] ;
>> x = si n ( k / 5 ) ;
>> st em ( k, x)
0 5 10 15 20 25 30
-1
-0.5
0
0.5
1
0 s k s 5
x

[

k

]
x [ k ] = sin ( k / 5 ) for 0 s k s 5
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
sin(x)
sin(x-.25)
sin(x-.5)
M ul t i pl e Dat a Set s i n One Graph
• M ul t i pl e x-y pai r ar gument s cr eat e mul t i pl e graphs w i t h a si ngl e cal l
t o pl ot . For exampl e, t hese st at ement s pl ot t hr ee r el at ed f unct i ons
of x, each cur ve i n a separat e di st i ngui shi ng col or.
x = 0:pi / 100:2* pi ;
y = si n(x);
y2 = si n(x-.25);
y3 = si n(x-.5);
pl ot (x,y,x,y2,x,y3)
l egend(' si n(x)' ,' si n(x-.25)' ,' si n(x-.5)' )
The l egend command pr ovi des an easy
way t o i dent i f y t he i ndi vi dual pl ot s.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Funct i on
• Synt ax
– f unct i on [ out 1, out 2, ...] = f unname(i n1, i n2, ...)
• Descr i pt i on
– f unct i on [ out 1, out 2, ...] = f unname(i n1, i n2, ...)
def i nes f unct i on f unname t hat accept s i nput s i n1,
i n2, et c. and r et ur ns out put s out 1, out 2, et c.
• Demo Exampl e
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Pr eci ous Ti p 1
Not i ce t hat t he ar ray subscr i pt s i n M at l ab st ar t f rom 1
and not 0 as i s t he case i n C.
Il l ust rat i on:
>> A = [ 1 2 3 4] ;
>> A(0) % Thi s command w i l l r esul t i n synt ax er ror
The f i rst i ndex i s 1 and not 0.
>> A(1)
ans = 1
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Pr eci ous Ti p 2
•Ti p 2: M ATLAB i s desi gned t o per f or m “ vect or operat i ons”. Long “ f or -l oops” on t he
ot her hand ar e not ef f i ci ent . You can see t hat by compar i ng t he f ol l ow i ng t wo pi eces
of code t hat do t he ver y same t hi ng: f i l l i ng an ar ray A w i t h 5’s.
X = 5 * ones(10^ 7,1);
OR
Y = zer os(10^ 7,1);
f or i = 1 : l engt h(A)
Y(i ) = 5;
end
Tr y r unni ng t he above t wo pi eces of codes (r ed and bl ue one) i n M at l ab (Just copy and
past e on t he command pr ompt ). Compar e t he t i me i t t akes f or M at l ab t o execut e
t hem. What do you concl ude?
Not e: t he r esul t s of t wo pi eces of code ar e t he same!
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
IM AGES
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Pi xel co-or di nat e
• The most conveni ent met hod f or expr essi ng l ocat i ons i n an
i mage i s t o use pi xel coor di nat es. In t hi s coor di nat e syst em,
t he i mage i s t r eat ed as a gr i d of di scr et e el ement s, or der ed
f r om t op t o bot t om and l ef t t o r i ght , as i l l ust r at ed by t he
f ol l owi ng f i gur e.
Pixel coordinat e syst em
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Image as M at r i ces
(
(
(
(
¸
(

¸

÷ ÷ ÷ ÷
÷
÷
=
) 1 , 1 ( .... ) 1 , 1 ( ) 0 , 1 (
.. ..
) 1 , 1 ( .... ) 1 , 1 ( ) 0 , 1 (
) 1 , 0 ( .... ) 1 , 0 ( ) 0 , 0 (
) , (
N M f M f M f
N f f f
N f f f
y x f
   
Each el ement of t hi s ar ray i s cal l ed and i mage el ement , pi ct ur e el ement , pi xel or pel .
A M ATLAB i mage can be r epr esent ed as a M ATLAB mat r i x:
(
(
(
(
¸
(

¸

÷
=
) , ( .... ) 2 , ( ) 1 , (
.. ..
) 1 , 1 ( .... ) 1 , 1 ( ) 1 , 2 (
) , 1 ( .... ) 2 , 1 ( ) 1 , 1 (
) , (
N M f M f M f
N f f f
N f f f
y x f
   
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Bi nar y Image
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Image Pr ocessi ng Commands
•Reading I mages
Images ar e r ead i nt o t he M ATLAB envi r onment usi ng f unct i on i mr ead, whose
synt ax i s
I mread( ‘f ilename’)
Her e, f i l ename i s a st r i ng cont ai ni ng t he compl et e name of t he i mage f i l e
(i ncl udi ng any appl i cabl e ext ensi on). For exampl e, t he command l i ne
>> f = imread ( ‘f low er. jpg’) ;
Reads t he JPEG i mage f l ower i nt o i mage ar ray f. The semi col on at t he end of
a command l i ne i s used by M ATLAB f or suppr essi ng out put . If a semi col on i s
not i ncl uded, M ATLAB di spl ays t he r esul t s of t he oper at i on(s) speci f i ed i n t hat
l i ne. Fi l e must be l ocat ed i n t he cur r ent di r ect or y or i n t he M ATLAB sear ch
pat h.
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
• Displaying I mages
>> imshow ( f )
>> imshow ( ‘f low er. jpg’)
Thi s command di spl ays t he i mage st or ed i n t he graphi cs f i l e. The f i l e must
cont ai n an i mage t hat can be r ead by i mr ead. The f i l e must be i n t he cur r ent
di r ect or y or on t he M ATLAB pat h.
>> w hos f
Name Si ze Byt es Cl ass At t r i but es
f 350x350x3 367500 ui nt 8
whos f ext ract basi c i nf or mat i on about t he i mage, and di spl ay i t .
Image Pr ocessi ng Commands
• Writ ing I mages
Images ar e wr i t t en t o di sk usi ng f unct i on i mwr i t e, whi ch has t he f ol l owi ng
basi c synt ax:
imw rit e ( f, ‘f ilename’)
e. g. imw rit e( f, ‘f low er1. png’)
Her e, t he above command wr i t es f t o a png f i l e named f l ower 1.
If f i l ename cont ai ns no pat h i nf or mat i on , t hen i mwr i t e saves t he f i l e i n t he
cur r ent wor ki ng di r ect or y. M ost of t he wor k deal s wi t h JPEG or TIFF
i mages, so we f ocus at t ent i on her e on t hese t wo f or mat s.
Image Pr ocessi ng Commands
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
• I mage compression
A mor e general i mwr i t e synt ax appl i cabl e onl y t o JPEG i mages i s
>> imw rit e ( f, ‘f ilename’, ‘qualit y’, q)
Wher e q i s an i nt eger bet ween 0 and 100 (t he l ower t he number t he hi gher
t he degradat i on due t o JPEG compr essi on).
In or der t o r educe st orage and t ransmi ssi on t i me, i t i s i mpor t ant t hat t he
i mages be compr essed as much as possi bl e whi l e not degradi ng t hei r
vi sual appearance beyond a r easonabl e l evel . In t hi s case ‘ r easonabl e’
means no per cept i bl e f al se cont our i ng.
Image Pr ocessi ng Commands
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Compr essi on
f l ower.j pg (184kb)
f l ower 50.j pg ( 20 kb)
i mwr i t e(f, ‘ f l ower 50.j pg’ , ‘qual i t y ’ , 50)
f l ower 30.j pg ( 16 kb)
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Funct i ons
• The f unct i on def i ni t i on l i ne has t he f or m:
Funct i on[ out put s] = name (i nput s)
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Pr oposed Pr oj ect s of Image Pr ocessi ng
• Any obj ect shape & col or det ect i on.
• To j udge si ze, shape & or i ent at i on of an obj ect .
• Aut omat i c at t endance syst em usi ng i mage pr ocessi ng (f ace
r ecogni t i on).
• Traf f i c l i ght cont r ol l er usi ng i mage pr ocessi ng (based upon no. of
vehi cl es on t he r oad).
• M easur e t he di st ance of obj ect s f r om camera (obst acl e avoi dance).
• Si gnat ur e r ecogni t i on.
• Saf et y al ar m f or a dr i ver i n dr owsi ness condi t i on(based on eye
bl i nki ng rat e).
• Secur i t y syst em.
• Obj ect Tracki ng
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Obj ect Tracki ng
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Lane Depar t ur e Syst em
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
Car Tracki ng
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com
• For f ur t her quer i es you can mai l me at -
• ashut osh.r et hym@gmai l .com
• Or cal l at - 9999645463
Prepared by : Ashut osh K. Agar wal
ashut osh.ret hym@gmai l .com

COMPANY INTRODUCTION
• blue ink infotech pvt. ltd. has started its journey in early 2008. Blue Ink is an incubatee company of Technology Business Incubator, KIET. • Company’s work domains are software development, web development, project development and training, e-learning and content management, Embedded Systems.
Prepared by : Ashutosh K. Agarwal ashutosh.rethym@gmail.com

Outline
Part I: Introduction and Overview (Case Study) Part II: MATLAB Desktop Part III: Types of Files Part IV: Matrix Manipulations, Common Functions, Plots in MATLAB • Part V: Image Processing Commands • Part VI: Model Demonstration • • • •

Prepared by : Ashutosh K. Agarwal ashutosh.rethym@gmail.com

What is MATLAB?
• MATLAB® (MATrix LABoratory) is a high-performance language for technical computing. It is an interactive system whose basic data element is an array that does not require dimensioning. Allows to solve many technical computing problems, examples of which include:
– – – – Matrix manipulation Finding the roots of polynomials Digital signal processing applications (toolbox) Plotting: x-y and polar, 3D graphics

Particularly helpful for: – Algorithm development, – Modeling, simulation, and prototyping, – Data acquisition – Data analysis, exploration, and visualization, – Application development, including graphical user interface building.
Prepared by : Ashutosh K. Agarwal ashutosh.rethym@gmail.com

Levels of Image Processing • There are no clear-cut boundaries in the continuum from image processing at one end to computer vision at the other. However. Agarwal ashutosh. a useful paradigm is to consider thee types of computerized processes: • Low level processes • Mid level processes • High level processes Prepared by : Ashutosh K.rethym@gmail.com .

but its outputs are attributes extracted from those images (e. such as image preprocessing to reduce noise. edges. and image sharpening.rethym@gmail. • Mid-level processes on images involve tasks such as segmentation (partitioning an image into regions or objects). contrast enhancement. contours. and classification (recognition) of individual objects. description of those objects to reduce them to a form suitable for computer processing. Prepared by : Ashutosh K. A low-level process is characterized by the fact that both its inputs and outputs typically are images. Agarwal ashutosh. and the identity of individual objects).com . A mid-level process is characterized by the fact that its inputs generally are images.Low level processes • A low level processes involve primitive operations.g.

High Level Processes • High level processing involves “making sense” of an ensemble of recognized objects. as in image analysis. Agarwal ashutosh.rethym@gmail. and. at far end of continuum.com . performing the cognitive functions normally associated with human vision. Prepared by : Ashutosh K.

rethym@gmail.com .Applications of Image Processing • • • • Weather forcasting Machine vision measuring distance of objects Object detection Finding an odd product on the conveyor belt • VIDEO DEMO Prepared by : Ashutosh K. Agarwal ashutosh.

and object-oriented programming features. input/output. – Application Program Interface (API) Prepared by : Ashutosh K. cosine.com .rethym@gmail. sine. matrix inverse. Agarwal ashutosh. and complex arithmetic. as well as annotating and printing these graphs. – MATLAB Mathematical Function Library • Collection of functions like sum. – The MATLAB Language • High-level matrix/array language with control flow statements. functions. and fast Fourier transforms. – Graphics • Provides extensive facilities for displaying vectors and matrices as graphs.MATLAB System • MATLAB system consists of five main parts – Development Environment • Set of tools and facilities that help you use MATLAB functions and files. data structures. matrix eigenvalues.

rethym@gmail. Agarwal ashutosh.MATLAB Desktop When you start MATLAB. MATLAB desktop appears.com . variables. containing tools (graphical user interfaces) for managing files. Prepared by : Ashutosh K. and applications associated with MATLAB.

rethym@gmail.com . Agarwal ashutosh.Help in MATLAB • >> help <functionname> Shows help document for a given function Example: help mean • >> lookfor <keyword> Searches all the help documents for a given keyword Example: lookfor average • >> demo Prepared by : Ashutosh K.

com . we need to generate a matlab programming file which is saved as xyz. Agarwal ashutosh.m (mat file) Prepared by : Ashutosh K.Types of Files • . But if it is required to execute/save a program.m file .command window is used to execute single command.rethym@gmail.

including: • Aerospace and Defense • Automotive • Communications • Electronics and Signal Processing • Medical Instrumentation by : Ashutosh K.SIMULINK • Simulink® software models. modeled in continuous time. Agarwal Prepared ashutosh. • Thousands of scientists and engineers around the world use Simulink to model and solve real problems in a variety of industries. simulates. sampled time. you can easily build models from scratch. and analyzes dynamic systems. Systems can also be multirate — having different parts that are sampled or updated at different rates.rethym@gmail. model the system. • With Simulink. or modify existing models to meet your needs. and see what happens. Simulink supports linear and nonlinear systems. or a hybrid of the two.com . It enables you to pose a question about a system.

Agarwal ashutosh. 7 8 9 ] x= 1 2 3 4 5 6 7 8 9 Note: Variable Names are case sensitive Variables: Scalars. as does 5+10*j x= 5. %”. 3 ].0000 +10.” supresses output >> x x= 1 2 3 Matrix (3 x 3) >> x = [ 1 2 3 .Real Scalars >> x = 5 x=5 Complex Scalars >> x = 5+10j %5+10i works.rethym@gmail. 4 5 6 . Vectors and Matrices Prepared by : Ashutosh K.0000i Row Vector (1 x 3) >> x = [ 1 2 3 ] x= 1 2 3 Column Vector ( 3 x 1) >> x = [ 1 . 2 .com .

00 Prepared by : Ashutosh K.com .00 >> x = linspace(0.80 1. 6) % 6 points from 0 to 1 on a linear scale x= 0 0.40 0.rethym@gmail.80 1.Generating Vectors and the Colon Operator >> x = [ 0 : 0.60 0.60 0.2 0. Agarwal ashutosh.20 0. 1.20 0.40 % 0 to 1 in increments of 0.2 : 1 ] x= 0 0.

2) ans = 1 1 1 1 >> zeros(2.3) % generates a random 3 x 3 matrix ans = 0.6154 0.9218 0.com .Generating Matrices >> B = [ 1 2 .3) ans = 0 0 0 0 0 0 % generates an all ones 2 x 2 matrix % generates an all zero 2 x 3 matrix >> rand(3.9355 0.7919 0. Agarwal ashutosh.9169 Prepared by : Ashutosh K. 8 9 ] ans = 1 2 8 9 >> ones(2.4057 0.4447 0.1763 0.7382 0.rethym@gmail.

Accessing Matrix Elements >> A= [ 1 2 3 . 3 ) x= 3 %A(<row>.com . 7 8 9]. A= 1 4 7 2 3 5 6 8 9 >> x = A ( 1. Agarwal ashutosh.rethym@gmail.<column>) Prepared by : Ashutosh K. 4 5 6 .

9273 %Phase angle (in radians). Agarwal ashutosh. >> conj(x) %Complex conjugate.com .Complex Number Operations >> x = 3+4j >> abs(x) %Absolute value. x=3 Prepared by : Ashutosh K. x = 3-4j >> imag(x) x=4 %Complex imaginary part. >> real(x) %Complex real part.rethym@gmail. x=5 >> angle(x) x = 0.

Some useful matrix and vector functions: >> size (A) ans = 3 3 >> length ( t ) ans = 1001 Prepared by : Ashutosh K. atan(x). Agarwal ashutosh.Some Useful Functions Some useful math functions: sin(x).com A= 1 4 7 2 3 5 6 8 9 .01 : 10 ]. sqrt(x) >> t = [ 0 : 0. tan(x). exp(x). log(x).rethym@gmail. cos(x). log10(x). >> x = sin ( 2 * pi * t ).

More Operators and Functions For vectors. SUM(X) is the sum of the elements of X.rethym@gmail. >> sum ( A ) ans = 12 15 18 >> sum ( ans ) ans = 45 >> A’ ans = % equivalent to sum(sum(A)) A= 1 4 7 2 3 5 6 8 9 % equivalent to transpose(A) 1 2 3 4 5 6 7 8 9 >> diag(A) ans = 1 5 9 What is sum(A')' ? Prepared by : Ashutosh K.com . SUM(X) is a row vector with the sum over each column. Agarwal ashutosh. For matrices.

Agarwal ashutosh.4034i Prepared by : Ashutosh K.8872 -0. >> r = roots(C) r= -1.0179 .4034i -0.com .Roots of Polynomials • Find the roots of the polynomial: 13 x3 + 25 x2 + 3 x + 4 >> C = [13 25 3 4].0.rethym@gmail.0179 + 0.

If y is a vector. If you specify two vectors as arguments.001 : 2*pi ]. plot(x.y) . Agarwal ashutosh. >> plot (x.com . 1 0.5 -1 0 1 2 3 4 5 6 7 >> x = [ 0 : 0.Continuous Time Plots • The plot function has different forms.5 0 -0.y) produces a graph of y versus x. plot(y) produces a piecewise linear graph of the elements of y versus the index its elements. Prepared by : Ashutosh K. >> y = sin ( x ).rethym@gmail. depending on the input arguments.

rethym@gmail. For more info: help stem • Example: >> k = [ 0 : 30 ] .5 -1 0 5 10 15 20 25 0  kPrepared by : Ashutosh K. It is used to plot discrete time sequences. >> stem ( k. Agarwal 5 30 ashutosh. x) • x [ k ] = sin ( k / 5 ) for 0  k  5 1 0.5 x[k] 0 -0.Discrete Time Plots – Stems Stem function is very similar to plot. >> x = sin ( k / 5 ) .com .

plot(x. 1 0.y3) legend('sin(x)'.x.25)'.5).2 -0.25) sin(x-. y = sin(x).rethym@gmail.y2.6 -0.6 0.25). these statements plot three related functions of x.8 sin(x) sin(x-. y3 = sin(x-.y. 0. Agarwal ashutosh. each curve in a separate distinguishing color.x.5) x = 0:pi/100:2*pi.com . For example. y2 = sin(x-.Multiple Data Sets in One Graph • Multiple x-y pair arguments create multiple graphs with a single call to plot.4 0.'sin(x-.2 0 -0.'sin(x-.8 -1 0 1 2 3 4 5 6 7 Prepared by : Ashutosh K.5)') The legend command provides an easy way to identify the individual plots.4 -0.

etc... etc.. in2. .] = funname(in1. out2. .com . out2.] = funname(in1.. • Demo Example Prepared by : Ashutosh K.. . and returns outputs out1. in2.) defines function funname that accepts inputs in1.Function • Syntax – function [out1.. in2. Agarwal ashutosh.rethym@gmail.) • Description – function [out1.. out2. ..

com .Precious Tip 1 Notice that the array subscripts in Matlab start from 1 and not 0 as is the case in C.rethym@gmail. >> A(0) % This command will result in syntax error The first index is 1 and not 0. Agarwal ashutosh. Illustration: >> A = [1 2 3 4]. >> A(1) ans = 1 Prepared by : Ashutosh K.

com . Agarwal ashutosh.1). Long “for-loops” on the other hand are not efficient. You can see that by comparing the following two pieces of code that do the very same thing: filling an array A with 5’s. What do you conclude? Note: the results of two pieces of code are the same! Prepared by : Ashutosh K. X = 5 * ones(10^7.1). OR Y = zeros(10^7. for i = 1 : length(A) Y(i) = 5.Precious Tip 2 •Tip 2: MATLAB is designed to perform “vector operations”. end Try running the above two pieces of codes (red and blue one) in Matlab (Just copy and paste on the command prompt). Compare the time it takes for Matlab to execute them.rethym@gmail.

rethym@gmail.IMAGES Prepared by : Ashutosh K.com . Agarwal ashutosh.

com . ordered from top to bottom and left to right. Pixel coordinate system Prepared by : Ashutosh K. the image is treated as a grid of discrete elements.rethym@gmail. as illustrated by the following figure. In this coordinate system. Agarwal ashutosh.Pixel co-ordinate • The most convenient method for expressing locations in an image is to use pixel coordinates.

...0) f ( x.. N  1)  f (1. f (1. N )  f (1. y )       f ( M  1. picture element. Agarwal ashutosh. A MATLAB image can be represented as a MATLAB matrix:  f (1.. N  1)      f ( M  1...1) f (1..0) f (0..1) .0)  f (1. y )       f ( M .1) . .. f (0.Image as Matrices  f (0..2) .  . N  1) Each element of this array is called and image element...1) f ( x..2) f (1.. pixel or pel. f ( M ....rethym@gmail. N )  Prepared by : Ashutosh K. ..1)  f ( 2..1) .1) f (1.com .  .. N  1)     f (M .. f ( M  1...

com .Binary Image Prepared by : Ashutosh K.rethym@gmail. Agarwal ashutosh.

the command line >> f = imread (‘flower.com . If a semicolon is not included. Reads the JPEG image flower into image array f. filename is a string containing the complete name of the image file (including any applicable extension). whose syntax is Imread(‘filename’) Here. File must be located in the current directory or in the MATLAB search path. MATLAB displays the results of the operation(s) specified in that line. The semicolon at the end of a command line is used by MATLAB for suppressing output.rethym@gmail.Image Processing Commands •Reading Images Images are read into the MATLAB environment using function imread. Agarwal ashutosh.jpg’) . For example. Prepared by : Ashutosh K.

Image Processing Commands • Displaying Images >> imshow (f) >> imshow (‘flower. The file must be in the current directory or on the MATLAB path.jpg’) This command displays the image stored in the graphics file. . >> whos f Name f Size Bytes 367500 Class uint8 Attributes 350x350x3 whos f extract basic information about the image. and display it. The file must contain an image that can be read by imread.

g. ‘filename’) e. If filename contains no path information . then imwrite saves the file in the current working directory. which has the following basic syntax: imwrite (f. ‘flower1.Image Processing Commands • Writing Images Images are written to disk using function imwrite. Prepared by : Ashutosh K.png’) Here. the above command writes f to a png file named flower1. Most of the work deals with JPEG or TIFF images.rethym@gmail.com . imwrite(f. Agarwal ashutosh. so we focus attention here on these two formats.

In this case ‘reasonable’ means no perceptible false contouring.Image Processing Commands • Image compression A more general imwrite syntax applicable only to JPEG images is >> imwrite (f. Agarwal ashutosh. ‘filename’. ‘quality’. Prepared by : Ashutosh K.com . it is important that the images be compressed as much as possible while not degrading their visual appearance beyond a reasonable level.rethym@gmail. q) Where q is an integer between 0 and 100 (the lower the number the higher the degradation due to JPEG compression). In order to reduce storage and transmission time.

rethym@gmail. ‘flower50. Agarwal ashutosh.jpg (184kb) flower50.jpg ( 20 kb) imwrite(f.Compression flower.jpg ( 16 kb) Prepared by : Ashutosh K.jpg’ .com . 50) flower30. ‘quality’ .

Agarwal ashutosh.rethym@gmail.com .Functions • The function definition line has the form: Function[outputs] = name (inputs) Prepared by : Ashutosh K.

• Security system. • Traffic light controller using image processing (based upon no.Proposed Projects of Image Processing • Any object shape & color detection.com . shape & orientation of an object. • Safety alarm for a driver in drowsiness condition(based on eye blinking rate). • Automatic attendance system using image processing (face recognition). of vehicles on the road). • Measure the distance of objects from camera (obstacle avoidance). Agarwal ashutosh. • Signature recognition.rethym@gmail. • Object Tracking Prepared by : Ashutosh K. • To judge size.

Agarwal ashutosh.Object Tracking Prepared by : Ashutosh K.com .rethym@gmail.

Lane Departure System Prepared by : Ashutosh K. Agarwal ashutosh.rethym@gmail.com .

Agarwal ashutosh.rethym@gmail.Prepared by : Ashutosh K.com .

Agarwal ashutosh.Car Tracking Prepared by : Ashutosh K.com .rethym@gmail.

9999645463 Prepared by : Ashutosh K.com .rethym@gmail.rethym@gmail. Agarwal ashutosh.• For further queries you can mail me at• ashutosh.com • Or call at.