A Brief Introduction to MATLAB Digital Image Processing 2014 Fall NTU.
-
Upload
candice-bradley -
Category
Documents
-
view
218 -
download
0
Transcript of A Brief Introduction to MATLAB Digital Image Processing 2014 Fall NTU.
A Brief Introduction to MATLAB
Digital Image Processing 2014 Fall NTU
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
MATLAB• NTU AppShare (臺大雲端軟體運算銀行 )
– Windows & IE
• https://app.ntu.edu.tw/vdiportal/
MATLAB interface
basic operation
variables• English alphabet, number, underline
– first word must be English alphabet– variable length <= 32 characters
• variables need not be previously declared (default double)
• comments– %
operators• arithmetic operators
– +, -, *, /, ^
• relational operators– ==, ~=, >, >=, <, <=
• logical operators– &, |, ~
• bitwise operators– bitand, bitor, bitxor
flow control• conditional control– if-else– switch
• loop control– for– while– continue
script
• or type “edit filename.m” to create a script from command window
Click to create a new script
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
matrix creation• row vector– R = [7 8 9 10];– R = [7, 8, 9, 10];
• column vector– C = [7; 8; 9; 10];
• build vector fast– start:step:end– linspace(start, end, num);
extract sub-matrix• A = [1 2 3 4; 5 6 7 8; 9 10 11 12];• B = A(1, 2:4);• C = A(2:3, 2:3);• D = A([1 3], [1 2 3]);
1 2 3 4
5 6 7 8
9 10 11 12
1 2 3 4
1
2
3
Matrix operations• add • Scalar
Matrix operation(Cont’d)• matrix multiplication • array multiplication
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
2-D plotting• Example 1: plot sin(x) and cos(x) over [0, 2]
subplot• Example 2: create figure with multiple graphs
Axis control• Axis control example:
histogram• hist(data): histogram plot– data = randn(1000, 3);– hist(data, 20);
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
3-D plotting• Example 1: mesh graph
3-D plotting (Cont’d)• Example 2: surface graph
3-D plotting (Cont’d)• Example 3: 3-d curve
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
overview• Basic commands:– img = imread(‘lena.jpg’, ‘jpg’);– imwrite(img, ‘my_lena.jpg’, ‘jpg’);– imfinfo(‘lena.jpg’)– image(img);
Image load and display
image scale• imresize(img, scale) – resize image
image rotation• I2 = imrotate(I, 60, ‘nearest’);• I3 = imrotate(I, 60, ‘bilinear’);
Nearest interpolation Bilinear interpolation
Original image
filter• h1 = fspecial(‘laplacian’);• f1 = filter2(h1, double(f)/255);• h2 = fspecial(‘sobel’);• f2 = filter2(h2, double(f)/255);
laplacian filter sobel filter
original image
edge detection• f3 = egde(f, ‘sobel’);• f4 = edge(f, ‘canny’);
edge detection by sobel method edge detection by canny method
original image
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
more about MATLAB• more on, more off: control paged output for
command window• help function_name: help for functions in
command window• lookfor keyword: search for keyword in all
help entries
Outline• MATLAB overview• Matrix• 2-D plotting• 3-D plotting• Image Processing• more about MATLAB• Reference
reference• Mathworks document• Mathworks forum• Tutorial from Jyh-Shing Roger Jang