You are on page 1of 17

IMAGE PROCESSING IN

MATLAB
LECTURE 1- EXPERTS VISION
STUFF COVERED EARLIER
 Creating variables
 Difference between script and a function
 Generating plots
 Implementing equations
 If else statements
 For loop
Creating variables
 To create a variable, simply assign value to a name.
 var1=3.14
 myString=‘hello world’
 The first character of a variable name must be a letter,
after that you can use any combination of letters,
numbers and ‘_’ symbol.
 To overwrite a variable, simply redefine it. Its value will
be updated in the workspace.
 The names of the variables are case sensitive, var1 is not
the same as VAR1!!
Built in variables of Matlab

 pi has the value 3.1415926…


 ans stores the last unassigned value (like on a
calculator)
 Inf and -Inf are positive and negative infinity
 NaN represents ‘Not a Number’
Plots and their options
 Type
 >>help plot
 And see all the options
Saving and loading workspace
 To save all workspace variables to a mat file, type:
 >>save myworkspace
 To save only the evariables a and b
 >>save my_savedvars a b
 After clearing the workspace, to load all those variables again:
 Double click that mat file from within matlab
 OR
 >>load('myworkspace.mat')
 OR
 >> load myworkspace.mat
An example
Exercise
 Do the following 5 things:
 Create the variable r as a row vector with values 1
4 7 10 13
 Create the variable c as a column vector with
values 13 10 7 4 1
 Save these two variables to file varEx
 clear the workspace
 load the two variables you just created
Other basic operations
 Exponentiation….. (^) (3+4*j)^2
 Log….. log(x)
 Sine, cos, tan……….sin(x) cos(x) tan(x) where x in
radians (cosd etc for degrees)
 Sin(x), asin(x), sind(x), asind(x)
 Inverse of sine, cos, tan……asin(x), acos(x), atan(x)
 Complicated expressions, use parentheses
 ((2+3)*3)^0.1
 Multiplication is NOT implicit given parentheses
Brackets do not imply
multiplication!
Built-in Functions
 MATLAB has an enormous library of built-in functions
 Call using parentheses – passing parameter to function
 sqrt(2)
 log(2), log10(0.23)
 cos(1.2), atan(-0.8)
 exp(2+4*i)
 round(1.4), floor(3.3), ceil(4.23)
 abs(1+i);

Understanding Vectors
Exercise
 Practice is all that matters to make you a good
programmer…. so practice as much as you can!

 Do ALL matrix concentation examples mentioned


on the previous slide. That's just the way you will
(in further lectures) concencate two images together!

 These are the very basics, once you get the hang of
these, the rest will come very naturally to you….
Automatic Initialization
Automatic Initialization
Exercise:

You might also like