Revision On MATLAB & Image Processing With Matlab
Revision On MATLAB & Image Processing With Matlab
Revision On MATLAB & Image Processing With Matlab
Outline
Matrices in MATLAB
Basic Operations on Matrices
Variable Name in Matlab
Logical Operators
Flow Control
Scripts and Functions
Visualization and Graphics
Saving your Work
What is the Image Processing ? ........
Matrices in MATLAB
Matrix is the main MATLAB data type
How to build a matrix?
A=[1 2 3; 4 5 6; 7 8 9];
Creates matrix A of size 3 x 3
Special matrices:
zeros(n,m), ones(n,m), eye(n,m),
rand(), randn()
Logical Operators
==, <, >, (not equal) ~=, (not) ~
find(condition) Returns indexes
of As elements that satisfy the condition
Idx=
3
4
6
Flow Control
MATLAB has five flow control constructs:
if statement
switch statement
for loop
while loop
break statement
if
IF statement condition
The general form of the IF statement is
IF expression
statements
ELSEIF expression
statements
ELSE
statements
END
switch
SWITCH Switch among several cases based
on expression
The general form of SWITCH statement is:
SWITCH switch_expr
CASE case_expr,
statement, , statement
OTHERWISE
statement, , statement
END
switch (cont.)
Note:
Only the statements between the matching
CASE and the next CASE, OTHERWISE, or END
are executed
Unlike C, the SWITCH statement does not fall
through (so BREAKs are unnecessary)
for
FOR repeats statements a specific
number of times
The general form of a FOR statement is:
FOR variable=expr
statements
END
while
WHILE repeats statements an indefinite
number of times
The general form of a WHILE statement
is:
WHILE expression
statements
END
CODE
CODE
Image
Processing?
Photo stitching
Color boost
Pixels
Pixel
RGB
Gray
Examples 1
Blending two images
Examples 2
Sobel descriptor to detect object edge
Binary Image
Greyscale Image
Color Image
Addition
Image:
I
Image:
I+50
Subtraction
Image:
I
Image: I80
Multiplication
Image:
I
Image: I*3
Division
Image:
I
Image: I/2
Complement
Image:
I
Image:
255-I
Matrix with
image data
image
filename as a
string
% load image
image
format as a
string
Representation of Images
Images are just an array of numbers
>> I % ctrl+c to halt output!
Intensity of each pixel is represented by the pixel
elements value in the red, green and blue matrices
>> I(1,1,:) % RGB values of element (1,1)
ans(:,:,1) =
Red
Images where the pixel value in the
135
image represents the intensity of the pixel
ans(:,:,2) =
are called intensity images.
Green
97
ans(:,:,3) =
Blue
33
Histograms
Frequency of the intensity values of the
image
Quantise frequency into intervals (called bins)
(Un-normalised) probability density function of
image intensities